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, wRcPlus
batting, fielding, baseRunning, positional, replacement (WAR components)
wSb, ubr, spd
Pitching:
war, fip, xfip, fipMinus
ra9War, eraMinus
pli, 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
Dependencies
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
Response Fields (Already mapped in SabermetricsResponse.java)
Batting:
war,woba,wRaa,wRc,wRcPlusbatting,fielding,baseRunning,positional,replacement(WAR components)wSb,ubr,spdPitching:
war,fip,xfip,fipMinusra9War,eraMinuspli,gmli(leverage)Files to Modify
ingestion/client/MlbApiClient.javaAdd methods:
ingestion/mapper/StatsMapper.javaAdd methods:
Files to Create
ingestion/service/SabermetricsIngestionService.javaWorkflow
Test Cases
Acceptance Criteria
Dependencies