fix: PitchingStat model missing combined_season attribute (500 on s_type=combined) #65

Open
opened 2026-03-17 22:15:03 +00:00 by cal · 1 comment
Owner

Summary

GET /api/v3/pitchingstats?s_type=combined returns 500 in both dev and production.

Error

type object 'PitchingStat' has no attribute 'combined_season'

Reproduction

curl "https://sba.manticorum.com/api/v3/pitchingstats?season=2&s_type=combined&limit=5" \
  -H "Authorization: Bearer <token>"
# → 500

s_type=regular and s_type=post work correctly. Only combined/total/all paths fail.

Root Cause

In app/routers_v3/pitchingstats.py, the get_pitstats handler branches on s_type:

elif s_type.lower() in ["combined", "total", "all"]:
    all_stats = PitchingStat.combined_season(season)

PitchingStat.combined_season() is referenced but never defined on the model. regular_season and post_season exist; combined_season does not.

Fix

Add a combined_season classmethod to the PitchingStat model that unions regular and postseason stats for the given season, matching the pattern of regular_season and post_season.

Discovered

Post-deploy smoke test against production — 2026-03-17.

## Summary `GET /api/v3/pitchingstats?s_type=combined` returns 500 in both dev and production. ## Error ``` type object 'PitchingStat' has no attribute 'combined_season' ``` ## Reproduction ```bash curl "https://sba.manticorum.com/api/v3/pitchingstats?season=2&s_type=combined&limit=5" \ -H "Authorization: Bearer <token>" # → 500 ``` `s_type=regular` and `s_type=post` work correctly. Only `combined`/`total`/`all` paths fail. ## Root Cause In `app/routers_v3/pitchingstats.py`, the `get_pitstats` handler branches on `s_type`: ```python elif s_type.lower() in ["combined", "total", "all"]: all_stats = PitchingStat.combined_season(season) ``` `PitchingStat.combined_season()` is referenced but never defined on the model. `regular_season` and `post_season` exist; `combined_season` does not. ## Fix Add a `combined_season` classmethod to the `PitchingStat` model that unions regular and postseason stats for the given season, matching the pattern of `regular_season` and `post_season`. ## Discovered Post-deploy smoke test against production — 2026-03-17.
Claude added the
ai-working
label 2026-03-17 22:31:02 +00:00
Claude removed the
ai-working
label 2026-03-17 22:34:07 +00:00
Collaborator

PR opened: #67

Added combined_season as a @staticmethod to PitchingStat in app/db_engine.py (+4 lines). The method mirrors BattingStat.combined_season — returns all rows for the given season with no week filter, covering both regular and postseason weeks. This resolves the AttributeError on s_type=combined/total/all.

PR opened: https://git.manticorum.com/cal/major-domo-database/pulls/67 Added `combined_season` as a `@staticmethod` to `PitchingStat` in `app/db_engine.py` (+4 lines). The method mirrors `BattingStat.combined_season` — returns all rows for the given season with no week filter, covering both regular and postseason weeks. This resolves the `AttributeError` on `s_type=combined/total/all`.
Claude added the
ai-pr-opened
label 2026-03-17 22:34:12 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 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#65
No description provided.