diff --git a/app/controllers/admins/graphs_controller.rb b/app/controllers/admins/graphs_controller.rb index 21f9b32ee..6b11392b8 100644 --- a/app/controllers/admins/graphs_controller.rb +++ b/app/controllers/admins/graphs_controller.rb @@ -82,10 +82,14 @@ def user_agents data: base_relation .where(name: name) - .group(:day) - .order(day: :asc) - .pluck(Arel.sql("day, count(*)")) - .map { |d| [d.first.to_datetime.to_i * 1000, d.last] } + .group("date_trunc('hour', created_at)") + .order("hour asc") + .pluck( + Arel.sql( + "date_trunc('hour', created_at) as hour, count(*) as hour_count" + ) + ) + .map { |d| [d.first.to_i * 1000, d.last] } } end .reject { |data| data[:data].map(&:last).all? { |count| count < 10 } }