feat: add limit/pagination to pitstats endpoint (#134) #158
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-merged
ai-pr-opened
ai-reviewed
ai-reviewing
ai-reviewing
ai-working
bug
enhancement
evolution
performance
phase-0
phase-1a
phase-1b
phase-1c
phase-1d
security
tech-debt
todo
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#158
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/134-feat-add-limit-pagination-to-pitstats-endpoint"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #134
Adds optional
limitquery parameter (default 100, max 500) toGET /api/v2/pitstats.Changes
app/routers_v2/pitstats.py: Addedlimit: Optional[int] = 100parameter; appliedall_stats.limit(max(0, min(limit, 500)))after all filters, before the CSV/JSON branch — both response paths honour the limit.Notes
countin the JSON response reflects the limited count (pre-existing pattern across all paginated endpoints).AI Code Review
Files Reviewed
app/routers_v2/pitstats.py(modified)Findings
Correctness
limit: Optional[int] = 100added toget_pit_stats; capped viamax(0, min(limit, 500))— correct, guards negative values and upper bound..limit()applied after all filters (aftergsfilter), before theif csv:branch — both CSV and JSON response paths honour the limit. ✅Optionalalready imported at line 3 — no missing import. ✅Security
Style & Conventions
Suggestions
limit: Optional[int] = 100vslimit: int = 100— PR #157 (awards) used the more precise non-Optional form sinceNoneis never an intended value. Both work identically in practice (FastAPI rejects non-integer input with a 422), butint = 100is more self-documenting. Not a blocker; flagging for consistency if the pattern gets standardised in a follow-up pass.countin the JSON response reflects the limited count, not the total matching rows — pre-existing pattern across all 8 paginated endpoints. Non-blocking; a follow-up issue to add atotalfield project-wide would address this cleanly.limit=0returns an empty response even when records exist (lower bound ofmax(0, ...)permits it). Same pedantic edge case as all prior PRs. Non-blocking.Verdict: COMMENT
Clean, correct implementation. Follows the established pagination pattern exactly. No blockers. Posting as COMMENT rather than APPROVED due to Gitea self-review restriction.
Automated review by Claude PR Reviewer
Reviewed by Claude PR reviewer — clean implementation, consistent with established pagination pattern. Approving.