fix: add combined_season classmethod to PitchingStat (#65) #67
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#67
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/major-domo-database-65"
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 #65
Summary
GET /api/v3/pitchingstats?s_type=combinedwas returning 500 becausePitchingStat.combined_season()was called in the handler but never defined on the model.Fix
Added
combined_seasonas a@staticmethodtoPitchingStatinapp/db_engine.py, matching the identical pattern already used byBattingStat.combined_season:This returns all pitching stats for the given season (both regular and postseason weeks), which is the correct semantics for
combined/total/all.Files Changed
app/db_engine.py— +4 lines,combined_seasonstaticmethod added toPitchingStatNotes
s_type=regularands_type=postwere unaffected (their methods already existed)BattingStat.combined_seasonandselect_season— no week filter, just season equalityAI Code Review
Files Reviewed
app/db_engine.py(modified — +4 lines)Findings
Correctness
PitchingStat.combined_seasonwas called atapp/routers_v3/pitchingstats.py:82but never defined on the model, causing the 500. The added method resolves this exactly.BattingStat.combined_season(line 982–987) precisely:Model.select().where(Model.season == season)with no week filter, returning all rows for the season — correct semantics for "combined".select_seasonandregular_seasonmethods.if all_stats.count() == 0) already handles the case where no rows match, so no additional defensive coding is needed here.Security
seasonis typed asintin the router signature, so no injection risk. Peewee parameterises the query automatically.Style & Conventions
@staticmethod, consistent with every other method in bothPitchingStatandBattingStat(e.g.select_season,regular_season,post_season).@staticmethod. Title-only typo, no code impact.PitchingStat.select_season(line 1174–1176) and the newcombined_seasonare now functionally identical. This duplication pre-exists the router's choice to callcombined_seasonrather thanselect_season— out of scope for this fix.Suggestions
BattingStat.combined_season's style would be nice for consistency, but the surroundingPitchingStatmethods don't have docstrings, so this isn't a regression.Verdict: APPROVED
Minimal, targeted fix that resolves a clear missing-method 500. The implementation is faithful to the established pattern with no side effects. Safe to merge.
Automated review by Claude PR Reviewer
Checkout
From your project repository, check out a new branch and test the changes.