Add cursor pagination - #861
Merged
greatest0fallt1me merged 3 commits intoJul 29, 2026
Merged
Conversation
…dictions feat(users): stable cursor pagination for user predictions
4 tasks
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.
Motivation
GET /api/users/:address/predictionsso large result sets can be streamed efficiently and deterministically.createdAttimestamp.Description
createdAt|idform and preservedlimitcoercion insrc/routes/users.tswithzodparsing.src/services/userService.tsby splitting the cursor intocreatedAtandidand applyingWHERE (createdAt < cursorTime) OR (createdAt = cursorTime AND id < cursorId)to match theORDER BY createdAt DESC, id DESCordering.nextCursoras an ISO timestamp plus prediction id (<createdAt.toISOString()>|<id>) from the last item on the page.tests/users.test.tsthat seed deterministiccreatedAtvalues and IDs, assert pagination across tied timestamps does not skip rows, and verify malformed cursors are rejected.Testing
npx eslint src/routes/users.ts src/services/userService.tswhich passed for the modified files.npm test -- --runInBand tests/users.test.tswhich could not complete due to unavailable local services (Postgres/Redis connection refused), so tests were not executed successfully in this environment.npm run lintandnpm run buildwhich failed due to pre-existing lint/type errors outside the scope of these changes; these failures are unrelated to the cursor pagination logic.Closes #209