WP-05: PlayerSeasonStats Incremental Update Logic #70
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
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#70
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
Implement
update_season_stats(game_id)— computes stat deltas from a completed game'sstratplayanddecisionrows, then upserts intoplayer_season_stats. Runs in the post-game callback.Repo:
databasePhase: 1a (Schema & Data Foundation)
Dependencies: WP-02
Complexity: L
Implementation
game_idas inputstratplayrows for that game(batter_id, batter_team_id)for batting stats(pitcher_id, pitcher_team_id)for pitching statsdecisionrows for W/L/S/H/BSINSERT ... ON CONFLICT (player_id, team_id, season) DO UPDATE SET hits = hits + excluded.hits, ...last_game_idandlast_updated_atNote:
team_winsandquality_startsare NOT computed.outsstored as raw integer (IP = outs/3 at eval time).Files
database/app/services/season_stats.pyTests (write first in
database/tests/test_season_stats_update.py)Plan reference:
docs/prd-evolution/PHASE1_PROJECT_PLAN.mdWP-05Schema change notice:
PlayerSeasonStatshas been split into two separate models —BattingSeasonStatsandPitchingSeasonStats— with descriptive column names.Relevant commits on
next-release:bd8e457— refactor: split PlayerSeasonStats into BattingSeasonStats and PitchingSeasonStats6580c1b— refactor: deduplicate pitcher formula and test constantsKey changes for this WP:
batting_season_statsandpitching_season_stats(player_id, team_id, season)on each table (unchanged pattern)strikeouts(notk/so),wins(notw),earned_runs,runs_allowed,wild_pitches,balks,games_started, etc.sac,ibb,gidp(batting);earned_runs,runs_allowed,hbp,wild_pitches,balks,games_started(pitching)Implemented and merged. Refractor system deployed to dev.