feat: cursor pagination on predictions (#345)#546
Merged
greatest0fallt1me merged 1 commit intoJul 26, 2026
Conversation
- Verified existing keyset (createdAt DESC, id DESC) cursor pagination implementation in predictionRepo.ts / cursor.ts / predictions.ts route against issue Predictify-org#345 acceptance criteria — implementation was already correct and complete. - Fixed remaining lint error: unused 'options' param in createApp (index.ts). - Fixed unused 'and' import + comment typo in reports/scheduled.ts (lint fix, unrelated pre-existing file touched only for the lint pass). - Added tests to close coverage gaps: - tests/cursor.test.ts: isAfter(), paginate(), and decodeCursor malformed- input branches. - tests/predictionsList.test.ts: marketId/status/outcome filter branches and the valid-cursor keyset predicate branch in listPredictions(). - Coverage on changed/verified files: predictionRepo.ts 100%, cursor.ts 94.4% stmts / 97.7% lines, predictions.ts 86.5% (uncovered lines are the unrelated /:id/explain route, out of scope for this issue). Known pre-existing issue (not introduced by this change, left out of scope): tests/predictions.test.ts fails to load createApp() because src/index.ts imports a non-existent 'webhooksRouter' from src/routes/webhooks.ts, which only exports 'createWebhooksRouter' (factory). Tracked separately; unrelated to cursor pagination.
|
@temisan0x Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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 #345
Summary
Investigated and verified the existing cursor pagination implementation for
GET /api/predictionsagainst this issue's acceptance criteria. The keyset pagination logic —(createdAt DESC, id DESC), matching migration0024_markets_created_at.sql's composite index — was already correctly implemented in:src/routes/predictions.ts— Zod-validated query params,nextCursorresponse envelopesrc/repositories/predictionRepo.ts— parameterised keyset WHERE predicate, limit+1 probe patternsrc/utils/cursor.ts— versioned opaque cursor encode/decodeNo changes were needed to the pagination logic itself.
Changes in this PR
optionsparam increateApp()→ renamed to_options(src/index.ts)andimport + a comment typo insrc/routes/reports/scheduled.ts(lint pass, unrelated file)tests/cursor.test.ts:isAfter(),paginate(), anddecodeCursormalformed-input branchestests/predictionsList.test.ts: marketId/status/outcome filter branches and the valid-cursor keyset predicate branch inlistPredictions()Coverage
predictionRepo.ts: 100% stmts/branch/funcs/linescursor.ts: 94.4% stmts, 97.7% lines (uncovered: onecatchblock, low value to test)predictions.ts: 86.5% (uncovered lines are the unrelated/:id/explainroute, out of scope for this issue)Known pre-existing issue (out of scope, not introduced here)
tests/predictions.test.tsfails to load becausesrc/index.tsimports a non-existentwebhooksRouterfromsrc/routes/webhooks.ts, which only exports acreateWebhooksRouter(deps)factory. This predates this branch and is unrelated to cursor pagination — flagging for a separate fix.Test output