WP-02: PlayerSeasonStats Peewee Model #67
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#67
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
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?
Description
Define the
player_season_statsPeewee model with all batting and pitching aggregate columns. This table is the materialized aggregate updated incrementally after each game. Career totals are derived by summing across seasons at query time.Repo:
databasePhase: 1a (Schema & Data Foundation)
Dependencies: None
Complexity: S
Key Columns
Batting:
games_batting,pa,ab,hits,hr,doubles,triples,bb,hbp,so,rbi,runs,sb,csPitching:
games_pitching,outs(raw — IP = outs/3 computed in formula engine),so(K),bb_allowed,hits_allowed,hr_allowed,wins,losses,saves,holds,blown_savesMeta:
last_game_id(FK),last_updated_atNote:
team_winsandquality_startsare NOT included (removed from scope).Files
database/app/models/season_stats.pydatabase/app/db_engine.py— register modelTests (write first in
database/tests/test_season_stats_model.py)Acceptance Criteria
(player_id, team_id, season)enforcedlast_game_idis nullable FK toStratGamePlan reference:
docs/prd-evolution/PHASE1_PROJECT_PLAN.mdWP-02PR opened: #82
Added
PlayerSeasonStatstodb_engine.pywith all batting/pitching/meta columns, UNIQUE constraint on(player_id, team_id, season), and two supporting indexes. Re-export module added atapp/models/season_stats.py. 17 tests written and passing.Note: The spec's pitching
so (K)column is namedkin the model to avoid collision with the battingsocolumn — WP-09 should accessstats.kfor pitcher strikeout counts.