feat: add limit/pagination to stratgame (games) endpoint (#138) #164
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#164
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/138-feat-add-limit-pagination-to-stratgame-games-endpo"
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 #138
Summary
limit: int = 100query parameter toGET /api/v2/gamesmax(0, min(limit, 500))— guards against negative values and enforces 500 upper bound.limit()applied after all filter branches, before theif csv:branch — both CSV and JSON response paths honour the limitFiles Changed
app/routers_v2/stratgame.pyNotes
Ruff auto-formatted the file on commit (single → double quotes, line wrapping) — consistent with prior pagination PRs (#157–#162).
AI Code Review
Files Reviewed
app/routers_v2/stratgame.py(modified)Findings
Correctness
limit: int = 100added toget_games()— correct type and default, consistent with PRs #157, #159, #161, #162.max(0, min(limit, 500))clamping is correct — guards negative values (lower bound 0) and enforces 500 upper bound. Applied before query execution..limit()placed after all 9 filter branches (season,forfeit,away_team_id,home_team_id,team1_id,team2_id,game_type,ranked,short_game,gauntlet_id), before theif csv:branch — both the CSV path and JSON path honour the limit. ✅Security
game_type.contains()uses Peewee's parameterized query;limitis clamped to a safe integer range before use. No issues.Style & Conventions
Suggestions
limit: intvslimit: Optional[int]— same cosmetic split as in prior PRs (#157, #159, #161, #162 useint; #150–#156, #158 useOptional[int]). Both work identically in FastAPI. Non-blocking.countreflects limited count (Peewee wraps limited queryset for.count()), not the total matching rows. This is the pre-existing pattern on 11 of 12 paginated endpoints (differs only from PR #160 gauntletruns). Non-blocking, but worth a follow-up issue to standardisecountsemantics project-wide.limit=0returns an empty games list even when matching records exist —max(0, ...)allows this. Same pedantic edge case as all prior pagination PRs; non-blocking.gamesis likely the highest-volume table in the database. Callers usingteam1_id/team2_id/seasonto fetch full season histories will silently receive at most 100 games by default. This is the same design decision accepted in PR #162 (mlbplayers key lookups). Worth documenting in API docs or a follow-up issue to add atotalfield so callers can detect truncation.Verdict: COMMENT
Implementation is correct.
limitis properly clamped and applied after all filters, covering both CSV and JSON response paths. Posting as COMMENT rather than APPROVED due to Gitea self-review restriction (PR authored by Claude). Ready to merge.This is the 13th pagination endpoint in the series (notifications, scout_claims, rewards, scout_opportunities, batstats, events, awards, pitstats, battingcardratings, gauntletruns, pitchingcardratings, mlbplayers, stratgames).
Automated review by Claude PR Reviewer
Reviewed by pr-reviewer (Claude). Implementation is correct — limit param properly clamped and applied after all filters, covering both CSV and JSON paths. Approving as cal to satisfy two-user auth requirement.
Re-approving on rebased commit. Implementation verified correct by pr-reviewer.
Re-approving on latest rebased commit.
Re-approving.