fix(sunburst-clock): respect startOfDay offset when rendering the clock#766
Conversation
The sunburst clock was ignoring the user's "Start of day" setting and always using calendar midnight (00:00) as the start of the visualization window. This meant the queried time range (e.g. 04:00-04:00 next day) didn't align with the clock's visual range (00:00-23:59), causing events between midnight and the startOfDay offset to appear missing. Pass the starttime (already offset-aware) from SunburstClock.vue into sunburst-clock.ts so both the data query and the visualization use the same 24h window. Also adjust the clock tick labels to be placed at 6-hour intervals relative to the actual start-of-day hour rather than hard-coded at 0/6/12/18. Fixes ActivityWatch#358
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to 3432f0b in 8 seconds. Click for details.
- Reviewed
61lines of code in2files - Skipped
0files when reviewing. - Skipped posting
0draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
Workflow ID: wflow_cohlSwGiHh6xW7vf
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #766 +/- ##
==========================================
- Coverage 25.67% 25.60% -0.08%
==========================================
Files 30 30
Lines 1741 1746 +5
Branches 316 319 +3
==========================================
Hits 447 447
+ Misses 1272 1233 -39
- Partials 22 66 +44 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Greptile SummaryFixes sunburst clock to correctly display activity data when using a non-midnight Key changes:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 3432f0b |
|
The |
I think this will look weird, ticks should be at "normal" tick positions for analog clocks, not relative to the startOfDay. But maybe add a special tick for "start of day"/"previous day"/"next day"? Idk what would look best here, but clearly some indication is needed to not confuse users. |
…ay marker Keep 6-hour ticks at standard positions (00:00, 06:00, 12:00, 18:00) for analog-clock familiarity. Add a special ☀ marker for the start-of-day boundary when it differs from midnight (e.g. 04:00 ☀ for the default setting).
|
Good call — updated in 3f97f87: ticks now stay at standard 24h positions (00:00, 06:00, 12:00, 18:00) like a normal analog clock, while the start-of-day boundary gets a special ☀ label (e.g. |
Problem
Fixes #358 — the sunburst clock visualization shows no data for the period between midnight (00:00) and the user's "Start of day" setting (default 04:00).
Root Cause
The bug was a mismatch between two separate 24-hour windows:
Query window (correct):
SunburstClock.vueusesthis.starttime = moment(date)wheredateis the timeperiod start, already offset-aware (e.g.2024-01-15T04:00:00). The query correctly fetches events from 04:00 to next-day 04:00.Visualization window (wrong):
sunburst-clock.ts'supdate()function ignored the queried range and instead calledstartOf('day')which resets to calendar midnight (00:00), thenendOf('day')for 23:59:59. So the clock tried to display a midnight–midnight window, but only had data from 04:00 onward. Events between midnight and 04:00 were simply never fetched.Fix
this.starttime(the offset-aware start moment) fromSunburstClock.vueintosunburst-clock.ts'supdate()as an optional third parameter.update(), use the providedstartOfDaymoment asroot_startinstead of resetting to calendar midnight.root_endbecomes exactly 24 hours later — matching the query window.startOfDay=04:00, ticks appear at 04:00, 10:00, 16:00, 22:00.Backward Compatibility
If no
startOfDayis passed (future callers of theupdate()API), behavior falls back to the originalstartOf('day')logic. The defaultstartOfDay=00:00case is also unchanged (midnight is still midnight).Testing
npm test)startOfDayto04:00(default) now shows activity data from midnight to 04:00 if any exists, and the clock ticks align to the correct hoursstartOfDayto00:00is unchanged (workaround no longer needed)Important
Fixes sunburst clock visualization to respect user's start of day setting by adjusting start and end times in
sunburst-clock.ts.this.starttimefromSunburstClock.vuetosunburst-clock.ts'supdate()as an optional parameter.update(), usestartOfDayforroot_startand setroot_end24 hours later, matching the query window.startOfDay.startOfDayis not provided, default tostartOf('day')logic.startOfDay=00:00behavior remains unchanged.startOfDay=04:00andstartOfDay=00:00.This description was created by
for 3432f0b. You can customize this summary. It will automatically update as commits are pushed.