š Legacy Stats Aggregator
ā¹ļø When to use this tool:
- Re-aggregate stats for a newly authenticated user who linked their account
- Creates new
aggregatedPlayerStats/{authUID} document from their legacy playerStats data
- Works with 2025 and earlier season-level data (not game-based)
ā
NO DUPLICATES - HYBRID APPROACH:
- Auth users: Aggregates from their linked player stats
- Legacy players (not migrated): Aggregates normally
- Migrated legacy profiles: SKIPPED (prevents duplicates)
- Optional auth: Works whether players sign in or not!
How the migration flag works:
- When someone links their account, their old legacy profile gets marked:
migrated: true
- This script skips any profile with
migrated: true
- If a player never signs in, their legacy profile keeps working
- Result: No duplicates, works for everyone!
Before running: Make sure you've updated firebase-auth.js with the migration marking code.