fix: assign order_by() return value in GET /api/v3/games (#24) #39
No reviewers
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-database#39
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/major-domo-database-24"
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?
Summary
order_by()returns a new queryset and does not sort in place; the previous code discarded the return value on both branches.sort == 'recent-first'and the default branch now reassignall_games = all_games.order_by(...)so the ORDER BY clause is included in the executed query.GET /api/v3/gameswill now be sorted correctly regardless of thesortparameter value.Files Changed
app/routers_v3/stratgame.py— lines 94-97 (original): added assignment oforder_by()return valueTest Plan
GET /api/v3/gameswith nosortparameter returns games ordered oldest-first (season ASC, week ASC, game_num ASC)GET /api/v3/games?sort=recent-firstreturns games ordered newest-first (season DESC, week DESC, game_num DESC)Closes #24
🤖 Generated with Claude Code
AI Code Review
Files Reviewed
app/routers_v3/stratgame.py(modified)Findings
Correctness
order_by()returns a new queryset and does not mutate in place. Both branches of theif sort == 'recent-first':block now correctly reassign the return value (all_games = all_games.order_by(...)), ensuring the ORDER BY clause is included in the executed SQL query.Security
sortparameter is only used in a string comparison, never passed unsanitized into a query.Style & Conventions
Suggestions
game_numfilter (lines 52–53 and 91–92 in the original) applies the sameWHEREclause twice. This is harmless (idempotent in SQL) but could be cleaned up in a follow-up PR.Verdict: APPROVED
The core bug fix is minimal, accurate, and correctly addresses the root cause. The additional reformatting is cosmetic. No blocking issues.
Automated review by Claude PR Reviewer