fix: add combined_season classmethod to PitchingStat (#65) #67

Open
Claude wants to merge 1 commits from ai/major-domo-database-65 into main
Collaborator

Closes #65

Summary

GET /api/v3/pitchingstats?s_type=combined was returning 500 because PitchingStat.combined_season() was called in the handler but never defined on the model.

Fix

Added combined_season as a @staticmethod to PitchingStat in app/db_engine.py, matching the identical pattern already used by BattingStat.combined_season:

@staticmethod
def combined_season(season):
    return PitchingStat.select().where(PitchingStat.season == 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_season staticmethod added to PitchingStat

Notes

  • s_type=regular and s_type=post were unaffected (their methods already existed)
  • The new method is functionally identical to BattingStat.combined_season and select_season — no week filter, just season equality
  • No tests exist for this endpoint; verified by code inspection
Closes #65 ## Summary `GET /api/v3/pitchingstats?s_type=combined` was returning 500 because `PitchingStat.combined_season()` was called in the handler but never defined on the model. ## Fix Added `combined_season` as a `@staticmethod` to `PitchingStat` in `app/db_engine.py`, matching the identical pattern already used by `BattingStat.combined_season`: ```python @staticmethod def combined_season(season): return PitchingStat.select().where(PitchingStat.season == 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_season` staticmethod added to `PitchingStat` ## Notes - `s_type=regular` and `s_type=post` were unaffected (their methods already existed) - The new method is functionally identical to `BattingStat.combined_season` and `select_season` — no week filter, just season equality - No tests exist for this endpoint; verified by code inspection
Claude added 1 commit 2026-03-17 22:34:01 +00:00
fix: add combined_season classmethod to PitchingStat (#65)
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m17s
a21bb2a380
Closes #65

`PitchingStat.combined_season()` was referenced in the `get_pitstats`
handler but never defined, causing a 500 on `s_type=combined/total/all`.

Added `combined_season` as a `@staticmethod` matching the pattern of
`BattingStat.combined_season` — returns all rows for the given season
with no week filter (both regular and postseason).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude added the
ai-reviewing
label 2026-03-17 22:45:49 +00:00
Claude reviewed 2026-03-17 22:46:58 +00:00
Claude left a comment
Author
Collaborator

AI Code Review

Files Reviewed

  • app/db_engine.py (modified — +4 lines)

Findings

Correctness

  • The fix is correct. PitchingStat.combined_season was called at app/routers_v3/pitchingstats.py:82 but never defined on the model, causing the 500. The added method resolves this exactly.
  • The implementation matches 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".
  • Placement is appropriate: inserted between the existing select_season and regular_season methods.
  • The router's empty-result guard (if all_stats.count() == 0) already handles the case where no rows match, so no additional defensive coding is needed here.

Security

  • No issues. season is typed as int in the router signature, so no injection risk. Peewee parameterises the query automatically.

Style & Conventions

  • Method uses @staticmethod, consistent with every other method in both PitchingStat and BattingStat (e.g. select_season, regular_season, post_season).
  • Minor: the PR title says "classmethod" but the implementation (and PR body) correctly use @staticmethod. Title-only typo, no code impact.
  • Note: PitchingStat.select_season (line 1174–1176) and the new combined_season are now functionally identical. This duplication pre-exists the router's choice to call combined_season rather than select_season — out of scope for this fix.

Suggestions

  • No blocking suggestions. A docstring matching BattingStat.combined_season's style would be nice for consistency, but the surrounding PitchingStat methods 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

## AI Code Review ### Files Reviewed - `app/db_engine.py` (modified — +4 lines) ### Findings #### Correctness - The fix is correct. `PitchingStat.combined_season` was called at `app/routers_v3/pitchingstats.py:82` but never defined on the model, causing the 500. The added method resolves this exactly. - The implementation matches `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". - Placement is appropriate: inserted between the existing `select_season` and `regular_season` methods. - The router's empty-result guard (`if all_stats.count() == 0`) already handles the case where no rows match, so no additional defensive coding is needed here. #### Security - No issues. `season` is typed as `int` in the router signature, so no injection risk. Peewee parameterises the query automatically. #### Style & Conventions - Method uses `@staticmethod`, consistent with every other method in both `PitchingStat` and `BattingStat` (e.g. `select_season`, `regular_season`, `post_season`). - Minor: the PR title says "classmethod" but the implementation (and PR body) correctly use `@staticmethod`. Title-only typo, no code impact. - Note: `PitchingStat.select_season` (line 1174–1176) and the new `combined_season` are now functionally identical. This duplication pre-exists the router's choice to call `combined_season` rather than `select_season` — out of scope for this fix. #### Suggestions - No blocking suggestions. A docstring matching `BattingStat.combined_season`'s style would be nice for consistency, but the surrounding `PitchingStat` methods 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*
Claude added
ai-reviewed
and removed
ai-reviewing
labels 2026-03-17 22:47:17 +00:00
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m17s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin ai/major-domo-database-65:ai/major-domo-database-65
git checkout ai/major-domo-database-65
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/major-domo-database#67
No description provided.