Repository navigation
Show sync activity per user (#7) - #35
Merged
Merged
Conversation
The preview of this branch was deleted when pull request #34 was closed, and opening #35 on the same commit did not start a new one. Claude-Session: https://claude.ai/code/session_01BLKZu4E8T123xzXASL2erH
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
|
the one that opened the PR can merge it then |
Three conflicts, all the ones ADR 0010 predicts: one nav line, one router line, and the generated route tree, which was regenerated rather than merged. The stale devices feature took ADR numbers 0015 and 0016, so the ADR on casting aggregates to int is renumbered 0017.
ADR 0015 landed on main while this branch was open: a page's state lives in
the URL. The window moves from useState to ?period=, declared on the route
with validateSearch and a zod catch('7d'), so a window can be bookmarked and
a hand-edited value falls back instead of throwing.
The sync trend feature landed. Same three conflicts as the last merge: one nav line, one router line, and the generated route tree, regenerated.
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 #7.
What changes
A Users entry in the left nav opens a page listing every user in the directory with, over a
switchable window of 7 days (the default), 30 days or 3 months: their number of syncs, total
submissions, distinct devices and last sync. Every column header sorts, and clicking it again
reverses. A user with no activity in the window keeps their row — zeros, an em-dash, dimmed —
because a supervisor looking for who went quiet needs to see them.
How it works
One SQL aggregate per window returns one row per user (41 of them); the browser re-sorts that
array in place, so only a change of window goes back to the server.
Two details in
src/features/user-activity/api/queries.tscarry the whole query:onclause of aleft join, not in awhere. In awhereitwould drop exactly the inactive users the ticket is about. This is Django's
FilteredRelation.::int. Postgres returnscount()asbigint, andpghandsbigintback as a string — measured:
"6066"against6066. Without the cast the table sorts"9"above
"10"and nothing errors.The window lives in the URL as
?period=7d|30d|90d— declared on the route withvalidateSearchand a zod
.catch('7d'), read withgetRouteApi('/users'), written withreplace: true. That isADR 0015, which landed on
mainwhile this branch was open; the window started inuseStateandwas moved. A window is now bookmarkable, and
/users?period=bogusredirects to?period=7dinstead of throwing. The server turns the enum into a cutoff date, and the query takes that date as
a parameter rather than calling
now(), so the tests pin the window instead of racing the clock.No migration: every column already exists.
New ADR
0017 — Cast aggregates to int in the SQL. It records the cast, rejects the alternative (a
global
pg.types.setTypeParser), and states the uncomfortable part: PGlite returns an uncastcount()as a number, so no test can catch a missing cast. Review is the only check. ADR 0003anticipated PGlite lacking something Neon has; this is the mirror image, where the test stays green.
What was checked
pnpm test), 13 of them new here;pnpm exec tsc --noEmitclean.all predate the window, repeat syncs from one device counted once, alphabetical order.
users last in both directions, the empty state.
One round of review found two real defects, both fixed here:
never left the username column passed it. New fixture (
10and9) disagrees with the alphabetand with text ordering; mutating the comparator now fails it.
placeholderData: keepPreviousData.Worth knowing
row will not appear in the preview. ADR 0006 makes districts go silent, not users. The behaviour
is covered by tests; it is just not demonstrable on seeded data.
::intin the compiled SQL (needs the builderexposed separately from the function that runs it), and moving
relativeDaysout of both tablecomponents into
src/ui/(it would editdevice-syncswhile other pairs are in it).Merged with main
stale-deviceslanded first. Three conflicts, all the ones ADR 0010 predicts: one line innav.ts, one inrouter.ts, and the generatedrouteTree.gen.ts, which was regenerated ratherthan hand-merged. That feature also took ADR numbers 0015 and 0016, so the ADR proposed here is
0017.
Spec:
docs/superpowers/specs/2026-09-18-user-activity-design.md(with a "changed after the spec"note) · Plan:
docs/superpowers/plans/2026-09-18-user-activity.md