patch lb timezones (#631)

* patch lb timezones

* fix nil
This commit is contained in:
Echo
2025-11-16 00:59:29 -05:00
committed by GitHub
parent 810f09828c
commit 25ea2c00db

View File

@@ -129,6 +129,19 @@ module Heartbeatable
).group_by { |row| row["user_id"] }
.transform_values do |rows|
timezone = rows.first["user_timezone"]
if timezone.blank?
Rails.logger.warn "nil tz, going to utc."
timezone = "UTC"
else
begin
TZInfo::Timezone.get(timezone)
rescue TZInfo::InvalidTimezoneIdentifier, ArgumentError
Rails.logger.warn "Invalid timezone for streak calculation: #{timezone}. Defaulting to UTC."
timezone = "UTC"
end
end
current_date = Time.current.in_time_zone(timezone).to_date
{
current_date: current_date,