Skip to content

Commit

Permalink
Clean up pghero reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
christoudias committed Nov 4, 2018
1 parent 7f051aa commit 9a768d3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/pghero/methods/connections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def recently_connected_users
users = select_all <<-SQL
SELECT distinct username
FROM "pghero_connection_stats"
WHERE database='primary' and captured_at > date_trunc('day', NOW() - interval '24 hours')
WHERE database='primary' and captured_at > date_trunc('day', NOW() - interval '3 hours')
ORDER by username
SQL
end
Expand All @@ -51,11 +51,11 @@ def connection_history_for_user(username)
history = select_all <<-SQL
SELECT date_trunc('minute', captured_at) as the_date, max(total_connections) as tot
FROM "pghero_connection_stats"
WHERE database='primary' and captured_at > date_trunc('day', NOW() - interval '24 hours') and username = '#{username}'
WHERE database='primary' and captured_at > date_trunc('day', NOW() - interval '3 hours') and username = '#{username}'
GROUP by username, date_trunc('minute', captured_at)
ORDER by date_trunc('minute', captured_at)
SQL
Hash[history.map{|h| [h[:the_date], h[:tot]]}]
this_history = Hash[history.map{|h| [h[:the_date].strftime("%a %l:%M %P"), h[:tot]]}]
end

def capture_connection_stats
Expand Down

0 comments on commit 9a768d3

Please sign in to comment.