Skip to content

Commit 7315d45

Browse files
committed
this probs works
1 parent 1ec6377 commit 7315d45

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

app/jobs/leaderboard_update_job.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def build_global(date, period)
3434
board = ::Leaderboard.find_or_create_by!(
3535
start_date: date,
3636
period_type: period,
37-
timezone_utc_offset: nil
37+
timezone_offset: nil
3838
) do |lb|
3939
lb.finished_generating_at = nil
4040
end
@@ -82,12 +82,14 @@ def build_global(date, period)
8282
def build_timezones(date, period)
8383
range = LeaderboardDateRange.calculate(date, period)
8484

85-
offsets = User.joins(:heartbeats)
86-
.where(heartbeats: { time: range })
87-
.where.not(timezone_utc_offset: nil)
88-
.distinct
89-
.pluck(:timezone_utc_offset)
90-
.compact
85+
active_timezones = User.joins(:heartbeats)
86+
.where(heartbeats: { time: range })
87+
.where.not(timezone: nil)
88+
.distinct
89+
.pluck(:timezone)
90+
.compact
91+
92+
offsets = active_timezones.map { |tz| User.timezone_to_utc_offset(tz) }.compact.uniq
9193

9294
Rails.logger.info "Generating timezone leaderboards for #{offsets.size} active UTC offsets"
9395

0 commit comments

Comments
 (0)