-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Overview
Integrate with the MLB Stats API sabermetrics endpoint to fetch official WAR, wOBA, wRC+, FIP, and other advanced metrics.
Parent Issue
Part of #94 (WAR and Advanced Stats)
MLB Stats API Endpoint
GET /people/{playerId}/stats?stats=sabermetrics&season={season}&group={hitting|pitching}
Response Fields (Already mapped in SabermetricsResponse.java)
Batting:
war,woba,wRaa,wRc,wRcPlusbatting,fielding,baseRunning,positional,replacement(WAR components)wSb,ubr,spd
Pitching:
war,fip,xfip,fipMinusra9War,eraMinuspli,gmli(leverage)
Files to Modify
ingestion/client/MlbApiClient.java
Add methods:
public SabermetricsResponse getBattingSabermetrics(Integer playerId, Integer season);
public SabermetricsResponse getPitchingSabermetrics(Integer playerId, Integer season);ingestion/mapper/StatsMapper.java
Add methods:
public void applySabermetrics(PlayerBattingStats stats, SabermetricData saber);
public void applySabermetrics(PlayerPitchingStats stats, SabermetricData saber);Files to Create
ingestion/service/SabermetricsIngestionService.java
@Service
public class SabermetricsIngestionService {
public void syncPlayerSabermetrics(Player player, Integer season);
public int syncAllPlayerSabermetrics(Integer season);
}Workflow
- After basic stats are synced (StatsIngestionService)
- Fetch sabermetrics for each player with stats
- Apply official WAR and components to entity
- Calculate gWAR using GwarCalculationService
- Save updated stats
Test Cases
- Sabermetrics response parsed correctly
- WAR, wOBA, wRC+ applied to batting stats
- FIP, xFIP applied to pitching stats
- Handles API errors gracefully
- Integration test with mock fixtures
Acceptance Criteria
- Official WAR ingested from MLB API
- wOBA and wRC+ populated
- FIP family metrics populated for pitchers
- gWAR calculated after sabermetrics applied
- Existing StatsMapperTest extended with new methods
Dependencies
- gWAR Schema: League Constants and Component Fields #169 (gWAR Schema)
- gWAR Calculation Service #170 (gWAR Calculation Service)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels