Repository navigation
Show sync activity per user (#7) - #34
Closed
beygorghor wants to merge 7 commits into
Closed
beygorghor wants to merge 7 commits into
beygorghor wants to merge 7 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
plmercereau
added a commit
that referenced
this pull request
Sep 18, 2026
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
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 travels as an enum (
7d/30d/90d); the server turns it into a cutoff date. Thequery takes that date as a parameter rather than calling
now(), so the tests pin the windowinstead of racing the clock.
No migration: every column already exists.
New ADR
0015 — 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),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).Spec:
docs/superpowers/specs/2026-09-18-user-activity-design.md·Plan:
docs/superpowers/plans/2026-09-18-user-activity.md