Skip to content

feat: cursor pagination on predictions (#345)#546

Merged
greatest0fallt1me merged 1 commit into
Predictify-org:mainfrom
temisan0x:task/predictions-cursor
Jul 26, 2026
Merged

feat: cursor pagination on predictions (#345)#546
greatest0fallt1me merged 1 commit into
Predictify-org:mainfrom
temisan0x:task/predictions-cursor

Conversation

@temisan0x

Copy link
Copy Markdown
Contributor

Closes #345

Summary

Investigated and verified the existing cursor pagination implementation for GET /api/predictions against this issue's acceptance criteria. The keyset pagination logic — (createdAt DESC, id DESC), matching migration 0024_markets_created_at.sql's composite index — was already correctly implemented in:

  • src/routes/predictions.ts — Zod-validated query params, nextCursor response envelope
  • src/repositories/predictionRepo.ts — parameterised keyset WHERE predicate, limit+1 probe pattern
  • src/utils/cursor.ts — versioned opaque cursor encode/decode

No changes were needed to the pagination logic itself.

Changes in this PR

  • Fixed the one remaining lint error: unused options param in createApp() → renamed to _options (src/index.ts)
  • Fixed an unused and import + a comment typo in src/routes/reports/scheduled.ts (lint pass, unrelated file)
  • Added tests to close coverage gaps on the three files above:
    • 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

  • predictionRepo.ts: 100% stmts/branch/funcs/lines
  • cursor.ts: 94.4% stmts, 97.7% lines (uncovered: one catch block, low value to test)
  • predictions.ts: 86.5% (uncovered lines are the unrelated /:id/explain route, out of scope for this issue)

Known pre-existing issue (out of scope, not introduced here)

tests/predictions.test.ts fails to load because src/index.ts imports a non-existent webhooksRouter from src/routes/webhooks.ts, which only exports a createWebhooksRouter(deps) factory. This predates this branch and is unrelated to cursor pagination — flagging for a separate fix.

Test output

Test Suites: 2 passed, 2 total
Tests:       50 passed, 50 total

- 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.
@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@greatest0fallt1me
greatest0fallt1me merged commit 1a01f96 into Predictify-org:main Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add cursor pagination on predictions (buffer #9)

2 participants