๐Ÿ“Š Stats Aggregator

Aggregate game-level stats into season and career totals

๐Ÿ”’ Admin Tool
๐Ÿ†• Game-Level Stats Support
  • 2025 Seasons (partial data): Splits saved to separate collection - does NOT affect production stats
  • 2026-summer and beyond: Full aggregation to production (acesBPI, career totals)
  • Career totals: Only recalculated for 2026+ aggregation
โœ… No Duplicates - Hybrid Approach
  • Auth users: Aggregates from their linked player stats
  • Legacy players: Aggregates normally (not migrated)
  • Migrated profiles: Skipped (prevents duplicates)
๐Ÿ“ˆ 2025 Splits Aggregation (Partial Data)
โ„น๏ธ About 2025 Splits Data
  • Game-level data for 2025 seasons is incomplete (only some teams/players)
  • Splits data is stored in a separate collection: aggregatedPlayerStats2025Splits
  • This does NOT modify production stats, acesBPI, or career totals
  • Player-splits page will load from this collection for 2025 seasons

Aggregate available 2025 game data into splits-only collection:

๐Ÿ’ก Tip: This only creates/updates split data (home/away, playoff/regular, vs opponent). Production acesBPI and career stats remain unchanged.
๐ŸŽฎ Step 1: Aggregate Game-Level Stats (2026+)
๐Ÿงช
TEST MODE ACTIVE
Data will be written to aggregatedPlayerStats_test โ€” production data is safe!

Select a season that uses game-level stats collection:

๐Ÿ’ก Tip: Use "Preview" first to see what will be aggregated without making any changes.
๐Ÿ”€ Merge Player Records

Copies all playerStats/{sourceId}/games/* and playerStats/{sourceId}/seasons/* documents into the target player, then marks the source aggregatedPlayerStats document as migrated: true so it is skipped by all aggregation and display logic. Source docs are not deleted โ€” verify the merge looks correct, then remove them manually in the Firestore console.

โšพ bWAR Calculator (Simplified)

Computes simplified bWAR for each player in the selected season using calibrated run weights. Writes bwarSimp to each player's season record in aggregatedPlayerStats. Players below the minimum PA threshold are written as 0. Run this after each aggregation pass.

Weights: wBB=0.30 ยท wFlat(1B/2B/3B)=0.70 ยท wHR=1.40 ยท Replacement=50% league avg ยท Min PA=20 ยท RPW=0.5ร—R/G

Averages R/G across all fall or summer seasons separately โ€” stabilizes the run environment instead of using only the current season's games. Falls back to current season if no historical data matches.
๐Ÿ”ฅ Hit Streak Calculator (Cross-Season)

Calculates hit streaks across all seasons for every player. Loads all game docs globally, sorts by date, and detects streaks that may span season boundaries. Notable threshold: 5+ games. Does not touch career totals or aggregatedPlayerStats.

๐Ÿ”„ Step 2: Career Recalculation (Optional)

Recalculates career totals from ALL seasons (historical + game-based). Only needed if data gets out of sync.

Initializing...