fix(dashboard): bucket earnings by day past 24h, and label points by their span - #125
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
The rule keyed off
duration > 7*24h, so only 30 days ever bucketed daily. It now keys offduration > 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 thearia-labelon 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
TestEarningsHistoryReportsItsBucketasserts both the reported bucket and the aggregation: three samples spanning two hours give 2 points hourly and 1 point daily.8/8 packages pass,
tscclean, 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.