Display local time in the browser

This commit is contained in:
Dan Milne
2025-11-10 07:53:20 +11:00
parent ce2feb4180
commit 5851e04e06
9 changed files with 85 additions and 15 deletions

View File

@@ -99,15 +99,17 @@ class AnalyticsController < ApplicationController
.group("DATE_TRUNC('hour', timestamp)")
.count
# Convert to chart format
# Convert to chart format - keep everything in UTC for consistency
timeline_data = (0..23).map do |hour_ago|
hour_time = hour_ago.hours.ago
hour_key = hour_time.strftime("%Y-%m-%d %H:00:00")
hour_key = hour_time.utc.beginning_of_hour
{
time: hour_time.strftime("%H:00"),
# Store as ISO string for JavaScript to handle timezone conversion
time_iso: hour_time.iso8601,
total: events_by_hour[hour_key] || 0
}
end.reverse
end
# Action distribution for pie chart
action_distribution = @event_breakdown.map do |action, count|