Actions
Feature #5
openEnhance BackfillOrchestrator to auto-fix problem games with metadata issues
Status:
Backlog
Priority:
Low
Assignee:
-
Start date:
12/31/2025
Due date:
% Done:
0%
Estimated time:
Description
Overview¶
Now that we fixed the admin dashboard bug (https://docs.v2.icydata.hockey/issues/4), we have an accurate list of "problem games". The BackfillOrchestrator should automatically detect and fix these problem games.
Current State¶
The BackfillOrchestrator currently handles:
- ✅ Incomplete features - Games with missing GameFeature records
- ✅ Stale scheduled games - FUT/PRE games that should have started (checked in
check_stale_scheduled_games)
But the admin dashboard also identifies:
3. ❌ Metadata problems - Final games with missing scores, venue, or teams
4. ❌ Stale live games - Live games not updated in 1+ hours
Proposed Enhancement¶
Add a new method to BackfillOrchestrator to detect and fix metadata problems:
def check_problem_games
# Find final games with metadata problems
problem_games = Game.joins(:season)
.where(seasons: { enabled: true })
.where(game_state: 'FINAL')
.where(
"home_score IS NULL OR away_score IS NULL OR venue IS NULL OR " \
"home_team_id IS NULL OR away_team_id IS NULL"
)
.order(:game_date)
.limit(10)
problem_games.each do |game|
logger.info("BackfillOrchestrator: Refetching game #{game.external_id} with metadata problems")
update_game_state(game)
end
# Also check for stale live games
stale_live = Game.joins(:season)
.where(seasons: { enabled: true })
.where(game_state: ['LIVE', 'CRIT'])
.where("last_polled_at IS NULL OR last_polled_at < ?", 1.hour.ago)
.limit(5)
stale_live.each do |game|
logger.info("BackfillOrchestrator: Updating stale live game #{game.external_id}")
update_game_state(game)
end
end
Implementation Plan¶
- Add
check_problem_gamesmethod to BackfillOrchestrator - Call it in the
processmethod (before or aftercheck_stale_scheduled_games) - Limit the number of problem games fixed per run (e.g., 10) to avoid overwhelming the queue
- Log which games are being fixed and why
- Update tests to cover the new functionality
Benefits¶
- Automatic self-healing for data quality issues
- Reduces manual intervention needed
- Ensures admin dashboard "Problem Games" section stays clean
- Catches games that may have had API failures during initial fetch
Notes¶
- Should run BEFORE the regular incomplete games processing
- Should respect the same "skip if live games exist" logic
- Should handle API errors gracefully (don't crash the entire orchestrator run)
- Consider adding metrics/alerts for persistent problem games
Related¶
- Issue #4: Admin dashboard bug fix (now accurately identifies problem games)
app/services/backfill_orchestrator.rb-
app/controllers/api/v1/admin/seasons_controller.rb-find_problem_gamesmethod for reference
Actions