Repository navigation
Chart syncs per day over the last 30 days - #39
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
DimitriKwihangana
force-pushed
the
feat/daily-sync-trend
branch
from
September 18, 2026 09:59
bcbbc25 to
db2ae97
Compare
bramj
approved these changes
Sep 18, 2026
This branch was successfully deployed
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.
Closes #5.
What changes for the user
A new Trend page at
/trendanswers whether device activity is rising or falling. It shows the last 30 days: a bar per day for the number of syncs, a line for the resources those syncs carried (submissions, org units and entities added together), and three numbers above the chart — total syncs, total resources, and the change against the previous 30 days.Days with no sync are drawn as zero rather than skipped, which is the point of the ticket: a line that jumps a silent day hides exactly the event the page exists to show.
The tooltip writes the day out in full, with how long ago it was:
4 September 2026 (14 days ago).How it works
listDailyActivitybuilds the 30 days with Postgresgenerate_seriesand left-joins the syncs onto it, so a silent day arrives as a real row of zeros. Enforcing that in SQL is what makes it testable in one place.getActivityTotalsreturns the current and previous window in one pass, split withcount(...) filter (where ...).nowis set by the tRPC procedure and never sent by the client, so the window cannot be moved from the browser and a test can still choose its own date. Days are bucketed in UTC.countandsumcarries an::intcast: Postgres returnsbigint, which thepgdriver hands back as a string.CompositeChart. Its stylesheet was missing from the root route — that is what lays out the chart tooltip and legend — so@mantine/charts/styles.cssis now loaded next to the core one.The dual axis, on purpose
The two series are about fifteen times apart, so the chart uses two y-axes. This goes against the usual advice: where the line sits against the bars is set by how the two scales are picked, not by the data, so the crossing point means nothing. Two stacked plots and a single shared axis were both mocked up and looked at; the single axis flattens the syncs series against the floor and cannot answer the ticket's question, and density won over the stacked plots because this page is read at a glance. There is a comment saying so in
ActivityChart.tsx.An ADR was drafted for this decision and deliberately left out at the author's request.
Tests
61 pass. Query tests on in-process Postgres cover the zero-filled days, the three counters, and both window boundaries.
ActivitySummaryandformatDayhave their own tests —formatDaycounts whole UTC days rather than elapsed hours, so a day does not become "yesterday" partway through the afternoon.ActivityCharthas no test: jsdom computes no layout, so a chart draws nothing there.Worth a reviewer's eye
pnpm testorpnpm buildcould have caught the bug above — only looking at the page did. Fits issue Add an end-to-end smoke test #9.relativeDaysinSyncTableoverlapsformatDay. Four duplicated lines, left alone so this branch does not edit another feature's file.