Skip to content

fix(dashboard): bucket earnings by day past 24h, and label points by their span - #125

Merged
flyworker merged 1 commit into
mainfrom
fix/earnings-daily-buckets
Sep 4, 2026
Merged

fix(dashboard): bucket earnings by day past 24h, and label points by their span#125
flyworker merged 1 commit into
mainfrom
fix/earnings-daily-buckets

Conversation

@flyworker

Copy link
Copy Markdown
Member

Selecting 7 days on Earnings and traffic mix returned 169 hourly points — a week of bars drawn in the width of a day, too thin to hover and too fine to read a trend from. Measured on a live node:

Window Before After
24h 25 points, 1h step unchanged
7d 169 points, 1h step ~8 points, 24h step
30d 11 points, 24h step unchanged

The rule keyed off duration > 7*24h, so only 30 days ever bucketed daily. It now keys off duration > 24h.

The labels were wrong in the same way

Every timestamp was rendered with toLocaleString(), so a bar holding a whole day was labelled with a time. "Sep 4, 14:00" on a point covering all of September 4th states something false about what was measured — it reads as an instant.

The series now reports bucket_seconds, and the chart formats from it: date alone for daily buckets, time for hourly. This applies to the axis ends, the hover readout, and the aria-label on every bar.

Sending the bucket rather than re-deriving it in the UI keeps one rule in one place — otherwise the two drift the next time either side changes.

Verified

TestEarningsHistoryReportsItsBucket asserts both the reported bucket and the aggregation: three samples spanning two hours give 2 points hourly and 1 point daily.

8/8 packages pass, tsc clean, rebuilt bundle included.

Not yet verified against the live API, because the bucketing is server-side and that node still runs the previous binary — I'll confirm with a real request after this deploys.

…their span

Selecting 7 days returned 169 hourly points: a week of bars drawn in the width
of a day, too thin to hover and too fine to read a trend from. Only 30 days was
bucketed daily, because the rule keyed off "longer than 7 days" rather than
"longer than a day".

Anything past 24 hours is now a daily bucket, so 7 days is about 8 bars instead
of 168.

The labels were wrong in the same way. Every timestamp was rendered with
toLocaleString, so a bar holding a whole day was labelled with a time — "Sep 4,
14:00" on a point that covers all of September 4th states something false about
what was measured.

The series now reports the interval each point spans and the chart formats from
that: date alone for daily buckets, time for hourly. Sending the bucket rather
than re-deriving it in the UI keeps one rule in one place; the two would
otherwise drift the next time either side changed.
@flyworker
flyworker merged commit 867b0a0 into main Sep 4, 2026
1 check passed
@flyworker
flyworker deleted the fix/earnings-daily-buckets branch September 4, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant