hackclub / hackclub/hackatime

Country scope filters users but daily window is still UTC for all. Intended?

Open
#1,489 0 comments 0 reactions 1 assignee Claimed by @skyfallwastaken View on GitHub
Dominant language
Ruby
Stars
204
Forks
167
Avg merge
19h 55m
Merged PRs (30d)
27

Description

### What's happening:
On the daily leaderboard, the 24 hour window is computed in UTC for everyone, regardless of timezone. Switching scope to my country filters who appears, but the time range is still UTC. So near a UTC day boundary the board shows mostly yesterday's data.

### Where in code:
The daily window is hard coded to UTC
```ruby
# app/services/leaderboard_date_range.rb
when :daily
(24.hours.ago...Time.current) # identical for every region
```

The LeaderBoardUpdateJob always build the the board with `timezone_utc_offset: nil` and LeaderboardService.get only looks up boards with `timezone_utc_offset: nil`. The country scope in `LeaderboardPageCache` filters entries by users.country_code but never shifts the time.

### What I found:
I saw #305 added timezone boards and #494 later removed them for country boards. I am not proposing reverting #494. I am asking about the gap, the daily window is still UTC even for the country scope.

### Question before I open a PR:
Is the UTC daily window intended or open to a fix? If open I'd like to localize the daily window to the viewer's timezone.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.