Repository navigation
Sort the admin account list on the server - #297
Merged
Merged
Conversation
Column headers on the Users page reordered only the rows already loaded, so a sort showed the top of one page as if it were the whole list. The sort is now a list input (sort, dir) applied in SQL to every match and paged by a keyset on (sort value, id); the web page, list_users and reelsaw users share it, and the sort lives in the page hash. PRINCIPLES gains "Sorting happens in the database", guarded by a test that fails when a paged component sorts rows in the browser. Signed-off-by: dillonstreator <dillonstreator@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Signed-off-by: dillonstreator <dillonstreator@gmail.com>
- The usage sorts reuse allTimeUsageSql in quota.ts; storedBytes() and the sort share storedBytesSql, so the quota and the order cannot count differently. - projects_upload_id_idx serves the "upload copied yet" lookup the Stored sort, the quota and upload cleanup run. - ORDER BY names the selected sort_value, so it is computed once per row. - lastActive is one SQL value (UTC) for both the shown time and the sort. - dir without sort is refused on every surface; the sort input says the usage keys order by usage.*. - reelsaw users --sort prints the column it sorted by. - users-sort-stack.test.ts pages every key both ways against the shown values; the guard test also covers nextCursor lists and sortable ListColumn headers. Signed-off-by: dillonstreator <dillonstreator@gmail.com>
…table-sorting-9881e5 Signed-off-by: dillonstreator <dillonstreator@gmail.com> # Conflicts: # apps/server/drizzle/meta/0059_snapshot.json # apps/server/drizzle/meta/_journal.json
Merged
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.
Problem
The sortable column headers on the admin Users page reordered only the rows already loaded (50 per page). Sorting by "Stored, biggest first" showed the biggest of the first page as if it were the biggest overall, and "Load more" appended rows out of that order.
Repro: have more accounts than one page, sort by Stored or Active, and compare the top rows with the same order done in SQL.
Fix
The sort is now part of the list query, applied by the database to every match:
admin.users.list/groupstakesort(name, status, projects, sourceMinutes, clipsRendered, storedBytes, lastActive, created) anddir. Each column is one SQL value per account (USER_SORT_SQL), paged by a keyset on (value, id). The cursor names its sort, so a cursor from another order is refused. Search with a sort pages over every match; without a sort, search still returns the best matches.#sort=storedBytes&dir=desc), and grouped sections page in the same order.list_userstakessortanddir;reelsaw userstakes--sortand--dir. The generated docs tables are refreshed.Closing the class
docs/PRINCIPLES.md(Scale), with a pointer inAGENTS.mdand onListColumn.sort.apps/server/test/list-sorting.test.ts(stack-free) fails when a web component that pages withuseInfiniteQueryalso calls.sort(/.toSorted(. The old Users page fails it.Notes
USER_SORT_SQLfor sorting and inusageByUserfor the numbers on each row. Comments in both places say to change them together.Testing
pnpm lint,docs:check, and the new guard test pass.