-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Overview
Add database schema to support Grove WAR (gWAR) calculation, including league constants table and component fields on stats tables.
Parent Issue
Part of #94 (WAR and Advanced Stats)
Schema Changes
New Table: league_constants
Stores yearly league-wide values needed for gWAR calculations:
CREATE TABLE league_constants (
id BIGSERIAL PRIMARY KEY,
season INTEGER NOT NULL UNIQUE,
lg_woba DECIMAL(5,4) NOT NULL, -- League wOBA (~0.310-0.320)
woba_scale DECIMAL(5,4) NOT NULL, -- wOBA scale factor (~1.15-1.25)
lg_r_per_pa DECIMAL(6,5) NOT NULL, -- League R/PA for replacement
fip_constant DECIMAL(4,2) NOT NULL, -- FIP constant (~3.10-3.20)
runs_per_win DECIMAL(4,2) DEFAULT 10.0,
created_at TIMESTAMP DEFAULT NOW()
);New Columns: player_batting_stats
ALTER TABLE player_batting_stats ADD COLUMN gwar DECIMAL(4,1);
ALTER TABLE player_batting_stats ADD COLUMN gwar_batting DECIMAL(5,1);
ALTER TABLE player_batting_stats ADD COLUMN gwar_baserunning DECIMAL(5,1);
ALTER TABLE player_batting_stats ADD COLUMN gwar_fielding DECIMAL(5,1);
ALTER TABLE player_batting_stats ADD COLUMN gwar_positional DECIMAL(5,1);
ALTER TABLE player_batting_stats ADD COLUMN gwar_replacement DECIMAL(5,1);
ALTER TABLE player_batting_stats ADD COLUMN oaa INTEGER;New Columns: player_pitching_stats
ALTER TABLE player_pitching_stats ADD COLUMN gwar DECIMAL(4,1);
ALTER TABLE player_pitching_stats ADD COLUMN gwar_pitching DECIMAL(5,1);
ALTER TABLE player_pitching_stats ADD COLUMN gwar_replacement DECIMAL(5,1);Entities to Update
PlayerBattingStats.java- Add gWAR component fieldsPlayerPitchingStats.java- Add gWAR fields
New Entities
LeagueConstants.java- Entity for league constantsLeagueConstantsRepository.java- Repository
Acceptance Criteria
- V14 migration applies cleanly on PostgreSQL
- V14 migration applies on H2 (tests)
- League constants seeded for 2022-2024
- Entity fields mapped correctly
- Leaderboard indexes created for gwar columns
Dependencies
- Depends on Schema: Advanced Sabermetric Statistics #123 (Advanced Sabermetrics Schema) being complete
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels