-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: improve admin user search coverage #1466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,8 +25,8 @@ | |
| const DEFAULT_ROLE = "user"; | ||
| const ADMIN_HANDLE = "steipete"; | ||
| const MAX_USER_LIST_LIMIT = 200; | ||
| const MAX_USER_SEARCH_SCAN = 5_000; | ||
| const MIN_USER_SEARCH_SCAN = 500; | ||
|
|
||
| export const getById = query({ | ||
| args: { userId: v.id("users") }, | ||
|
|
@@ -362,15 +362,14 @@ | |
| return trimmed ? trimmed : undefined; | ||
| } | ||
|
|
||
| function computeUserSearchScanLimit(limit: number) { | ||
| return clampInt(limit * 10, MIN_USER_SEARCH_SCAN, MAX_USER_SEARCH_SCAN); | ||
| } | ||
|
|
||
| async function queryUsersForAdminList( | ||
| ctx: { | ||
| db: { | ||
| query: (table: "users") => { | ||
| order: (order: "desc") => { take: (n: number) => Promise<Doc<"users">[]> }; | ||
| order: (order: "desc") => { | ||
| take: (n: number) => Promise<Doc<"users">[]>; | ||
| collect: () => Promise<Doc<"users">[]>; | ||
| }; | ||
| }; | ||
| }; | ||
| }, | ||
|
|
@@ -384,7 +383,7 @@ | |
| return { items, total: items.length }; | ||
| } | ||
|
|
||
| const scannedUsers = await orderedUsers.take(computeUserSearchScanLimit(args.limit)); | ||
| const scannedUsers = await orderedUsers.collect(); | ||
|
||
| const result = buildUserSearchResults(scannedUsers, normalizedSearch); | ||
|
Comment on lines
379
to
382
|
||
| return { items: result.items.slice(0, args.limit), total: result.total }; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MAX_USER_SEARCH_SCAN/MIN_USER_SEARCH_SCANare now unused after removingcomputeUserSearchScanLimit. WithnoUnusedLocals: truein tsconfig, this will fail TypeScript compilation; remove these constants or reintroduce usage (e.g., as a cap for the search scan).