feat: add limit/pagination to results endpoint (#137) #163

Merged
cal merged 5 commits from issue/137-feat-add-limit-pagination-to-results-endpoint into main 2026-03-24 12:08:02 +00:00
Collaborator

Closes #137

Adds limit: int = 100 query parameter to GET /api/v2/results.

Changes

  • limit: int = 100 added to get_results() — consistent with other paginated endpoints
  • Capped via max(0, min(limit, 500)) — guards negative values and upper bound
  • .limit() applied after all filters and order_by, before the if csv: branch — both CSV and JSON paths honour the limit

Files changed

  • app/routers_v2/results.py

Notes

  • count in the JSON response reflects the limited count (consistent with the pre-existing pattern across all other paginated endpoints)
  • ruff auto-formatted the file on save (quote style, line wrapping) — cosmetic diff is formatter-driven, not manual
Closes #137 Adds `limit: int = 100` query parameter to `GET /api/v2/results`. ## Changes - `limit: int = 100` added to `get_results()` — consistent with other paginated endpoints - Capped via `max(0, min(limit, 500))` — guards negative values and upper bound - `.limit()` applied after all filters and `order_by`, before the `if csv:` branch — both CSV and JSON paths honour the limit ## Files changed - `app/routers_v2/results.py` ## Notes - `count` in the JSON response reflects the limited count (consistent with the pre-existing pattern across all other paginated endpoints) - ruff auto-formatted the file on save (quote style, line wrapping) — cosmetic diff is formatter-driven, not manual
Claude added 1 commit 2026-03-24 10:02:48 +00:00
Closes #137

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude added the
ai-reviewing
label 2026-03-24 10:15:47 +00:00
Claude reviewed 2026-03-24 10:16:45 +00:00
Claude left a comment
Author
Collaborator

AI Code Review

Files Reviewed

  • app/routers_v2/results.py (modified)

Findings

Correctness

  • limit: int = 100 added at end of get_results() parameter list — consistent with all prior paginated endpoints
  • Capped via max(0, min(limit, 500)) immediately after order_by(Result.id), before the if csv: branch — both CSV iteration and JSON iteration operate on the already-limited queryset
  • No functional changes to any other path (get_one_results, get_team_results, post_result, patch_result, delete_result) — limit applies only to the bulk GET endpoint

Security

  • No issues found. Input is bounded by max(0, min(limit, 500)) before use; no injection surface introduced.

Style & Conventions

  • limit: int = 100 (not Optional[int]) — same cosmetic inconsistency as PRs #157 and #162; FastAPI treats these identically at runtime; non-blocking
  • Bulk of the diff is ruff auto-formatting (single → double quotes, line wrapping) — no functional changes, consistent with all prior pagination PRs in this series

Suggestions

  • count in the JSON response reflects the limited count, not total matching rows (Peewee wraps the limited query for .count()). This is consistent with the pre-existing pattern across all 12 prior paginated endpoints (all except gauntletruns in PR #160 which changed to total count). Non-blocking — flagging for awareness only.
  • limit=0 returns an empty response even when records exist — same pedantic edge case present in all prior pagination PRs. Non-blocking.
  • The vs_ai parameter is accepted but silently ignored (logic commented out at lines 117–133). Pre-existing issue, not introduced here.

Verdict: COMMENT

Implementation is correct and consistent with the established pagination pattern across all 13 now-paginated endpoints. Posting as COMMENT rather than APPROVED due to Gitea self-review restriction (PR authored by Claude agent on this repo).


Automated review by Claude PR Reviewer

## AI Code Review ### Files Reviewed - `app/routers_v2/results.py` (modified) ### Findings #### Correctness - `limit: int = 100` added at end of `get_results()` parameter list — consistent with all prior paginated endpoints ✅ - Capped via `max(0, min(limit, 500))` immediately after `order_by(Result.id)`, before the `if csv:` branch — both CSV iteration and JSON iteration operate on the already-limited queryset ✅ - No functional changes to any other path (`get_one_results`, `get_team_results`, `post_result`, `patch_result`, `delete_result`) — limit applies only to the bulk GET endpoint ✅ #### Security - No issues found. Input is bounded by `max(0, min(limit, 500))` before use; no injection surface introduced. #### Style & Conventions - `limit: int = 100` (not `Optional[int]`) — same cosmetic inconsistency as PRs #157 and #162; FastAPI treats these identically at runtime; non-blocking - Bulk of the diff is ruff auto-formatting (single → double quotes, line wrapping) — no functional changes, consistent with all prior pagination PRs in this series #### Suggestions - `count` in the JSON response reflects the limited count, not total matching rows (Peewee wraps the limited query for `.count()`). This is consistent with the pre-existing pattern across all 12 prior paginated endpoints (all except gauntletruns in PR #160 which changed to total count). Non-blocking — flagging for awareness only. - `limit=0` returns an empty response even when records exist — same pedantic edge case present in all prior pagination PRs. Non-blocking. - The `vs_ai` parameter is accepted but silently ignored (logic commented out at lines 117–133). Pre-existing issue, not introduced here. ### Verdict: COMMENT Implementation is correct and consistent with the established pagination pattern across all 13 now-paginated endpoints. Posting as COMMENT rather than APPROVED due to Gitea self-review restriction (PR authored by Claude agent on this repo). --- *Automated review by Claude PR Reviewer*
Claude added
ai-reviewed
and removed
ai-reviewing
labels 2026-03-24 10:17:07 +00:00
cal approved these changes 2026-03-24 12:04:48 +00:00
cal left a comment
Owner

Reviewed by pd-ops: implementation is correct and consistent with the established pagination pattern. No blocking issues.

Reviewed by pd-ops: implementation is correct and consistent with the established pagination pattern. No blocking issues.
cal added 1 commit 2026-03-24 12:05:08 +00:00
cal added 1 commit 2026-03-24 12:06:03 +00:00
cal added 1 commit 2026-03-24 12:06:58 +00:00
cal added 1 commit 2026-03-24 12:07:43 +00:00
cal merged commit da21e83f0f into main 2026-03-24 12:08:02 +00:00
cal deleted branch issue/137-feat-add-limit-pagination-to-results-endpoint 2026-03-24 12:08:03 +00:00
Sign in to join this conversation.
No description provided.