feat: add limit/pagination to batstats endpoint (#133) #155
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#155
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/133-feat-add-limit-pagination-to-batstats-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 #133
Adds
limitquery param (default 100, max 500) toGET /api/v2/batstats.Changes:
limit: Optional[int] = 100toget_batstatssignaturemax(0, min(limit, 500))to guard negative values and cap at 500.limit()to query before both CSV and JSON response branchesFiles changed:
app/routers_v2/batstats.pyOther observations: The existing params like
card_id: int = Noneuse a pre-existing pattern ofint = None(withoutOptional) — Pyright flags these as type errors but they are pre-existing and not introduced by this PR.AI Code Review
Files Reviewed
app/routers_v2/batstats.py(modified)Findings
Correctness
Optionalis already imported at line 4 (from typing import Optional, List) — no missing import.limit: Optional[int] = 100added correctly toget_batstatssignature.max(0, min(limit, 500))correctly guards both negative values and the upper cap — this is the improved form (vs. themin-only version in PR #150 that allowedLIMIT -1)..limit()applied toall_statsbefore theif csv:branch — both CSV and JSON paths correctly honour the limit. ✅Security
Style & Conventions
notifications,scout_claims,rewards, andscout_opportunitiesendpoints.int = None(withoutOptional) on other params is noted in the PR body and is out of scope for this review.Suggestions
countin the JSON response (line 120) reflects the limited count, not the total number of matching rows. This is a pre-existing pattern across all four previously paginated endpoints. A follow-up issue to add atotalfield (or renamecountto clarify) would benefit all five endpoints consistently — no action needed here.limit=0returns an empty response even when records exist.max(0, ...)intentionally allows this; a lower bound of 1 would prevent the edge case. Same pedantic note as PRs #149, #151, #152, #154 — no action needed.Verdict: COMMENT
Clean implementation that correctly follows the established pagination pattern. The
max(0, min(limit, 500))clamp is the right form (improvement over the original PR #150 pattern). Both minor observations are pre-existing patterns across the codebase and do not block merging.Automated review by Claude PR Reviewer
Reviewer verdict is COMMENT (no blocking issues). Approving to merge.