Fix the 1D tab showing all-time totals on rollup-only stats panels - #224
Merged
Conversation
Exit pages, devices, browsers and operating systems have no sub-day data source, so #222 gave them the rollup ranges only — with "1D" documented to mean today's UTC rollup rather than a rolling 24 hours. But the 1D range object is defined with `minutes: 1440` and no `days`, since it is a raw-event window for every other panel. resolveDays looks for `days`, finds nothing, and falls through to tracker_first_day, which returns the project's entire history. So those four panels answered the 1D tab with all-time totals, and on any site younger than 30 days 1D, 1M and All were byte-identical. rssamplifier.com is 15 days old, which is how this surfaced: its exit-pages card read 169,207 for /login at 1D, 1M and All alike, while the top-pages card — raw-backed, and therefore correct — read ~4k for the same path over the same 24 hours. Today's actual figure is 536. A sub-day window against a day-resolution rollup is one day, so rollupDays() collapses any raw range to 1 for these panels and passes real rollup ranges through untouched. The 1D tooltip is relabelled from "Last 24 hours, hourly buckets" to "Today so far, UTC day" for the same four panels, so the tab no longer promises a rolling window it cannot serve. Panels with a raw source are unaffected. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WaCMqhvNYfKtjLHmHQD1oq
ThreatCrush Security Scan40 finding(s) HIGH/CRITICAL: 3 | MEDIUM: 28 | LOW: 9
Snippets are redacted; ThreatCrush never prints matched credential material. |
EmptyRange looked the range description up in the global table, so an exit pages / devices / browsers / OS card with no data for 1D still said "last 24 hours, hourly buckets" while its own tab tooltip said "today so far, UTC day". Both call sites already hold the panel's range list; pass it through and read the label from there, falling back to the global lookup. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WaCMqhvNYfKtjLHmHQD1oq
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.
Exit pages, devices, browsers and operating systems have no sub-day data source, so #222 gave them the rollup ranges only — with "1D" documented to mean today's UTC rollup rather than a rolling 24 hours.
But the
1drange object is defined withminutes: 1440and nodays, since it is a raw-event window for every other panel.resolveDayslooks fordays, finds nothing, and falls through totracker_first_day, which returns the project's entire history. So those four panels answered the 1D tab with all-time totals, and on any site younger than 30 days 1D, 1M and All were byte-identical.How it surfaced
rssamplifier.com is 15 days old. Its exit-pages card read 169,207 for
/loginat 1D, 1M and All alike, while the top-pages card — raw-backed, and therefore correct — read ~4k for the same path over the same 24 hours. That gap is what made it look like a stats bug rather than a traffic spike.Verified against the rollups directly:
/login/loginThe data was always right; only the day resolution was wrong.
The fix
rollupDays()collapses any raw range to 1 for these four panels and passes real rollup ranges through untouched. The 1D tooltip is relabelled from "Last 24 hours, hourly buckets" to "Today so far, UTC day" for the same panels, so the tab no longer promises a rolling window it cannot serve. Panels with a raw source are unaffected —pagesat 1D still hitstracker_recent_top_pageswithp_minutes: 1440.Testing
tests/tracker-rollup-ranges.test.tspins all of it: the 1D/1M day resolution per panel, the relabelled tooltip, and that raw-capable panels keep their 7 tabs and rolling source.Local install is broken at HEAD (the
@profullstack/autoblogpin), so there is no local vitest or tsc — the assertions were run by bundling the module graph with esbuild, 25/25 passing, and CI is the real gate here.🤖 Generated with Claude Code
https://claude.ai/code/session_01WaCMqhvNYfKtjLHmHQD1oq