Bug #4
closedAdmin season dashboard incorrectly marking games with 'incomplete features' in problem games section
100%
Description
Problem¶
The admin season dashboard is showing games in the "Problem Games" section with the label "incomplete features" when those games actually have all features completed.
Location¶
Admin Season Dashboard → Problem Games section
Expected Behavior¶
- Games should only appear in "Problem Games" if they genuinely have incomplete features
- The "incomplete features" label should only show for games where one or more features are not completed
- Completed games should not appear in this section
Actual Behavior¶
- Games are appearing in "Problem Games" section with "incomplete features" label
- These games may actually have all features marked as completed
- This creates false positives and makes it hard to identify genuinely problematic games
Impact¶
- Admins cannot trust the dashboard to identify real issues
- Time wasted investigating false positives
- May hide genuinely problematic games in the noise
- Dashboard loses credibility as a monitoring tool
Investigation Areas¶
-
Feature completion logic: Check how
game.game_featurescompletion status is being evaluated - Preseason games: Are preseason games being incorrectly flagged? (We skip preseason data collection)
- Feature definitions: Are all expected features properly defined for each league?
- Race conditions: Could there be timing issues where features are marked complete after the dashboard queries?
- Query logic: Review the SQL/ActiveRecord query that identifies "problem games"
Related Code¶
Likely locations:
- Admin dashboard controller/view code
-
GameFeaturemodel and completion logic - Season/Game associations with features
- Feature definition in League model
Reproduction Steps¶
- Navigate to admin season dashboard
- Look at "Problem Games" section
- Observe games marked with "incomplete features"
- Check those games'
game_featuresrecords - Verify if features are actually incomplete or if it's a false positive
Suggested Investigation¶
# Check a specific game's features
game = Game.find_by(external_id: GAME_ID)
game.game_features.each do |gf|
puts "Feature: #{gf.feature.name}, Completed: #{gf.completed?}, Status: #{gf.status}"
end
# Check what the dashboard query is doing
# Review the query used to identify problem games
Priority¶
Medium - Dashboard accuracy is important for monitoring, but doesn't affect data collection or user-facing features.
Updated by William Lang about 2 months ago
Starting investigation into the problem games logic in admin season dashboard.
Updated by William Lang about 2 months ago
Fix Implemented¶
Root Cause Identified:
The "Problem Games" section in the admin season dashboard was comparing game feature completion against all enabled features across all leagues, rather than just the features for the game's specific league.
Location:
app/controllers/api/v1/admin/seasons_controller.rb - find_problem_games method (lines 441-499)
The Bug:
Two places in the code were using Feature.enabled.count which counts all features:
-
Line 458 - Query to find incomplete games:
.having("...", Feature.enabled.count) # Wrong: counts ALL features -
Lines 481-486 - Issue detection logic:
total_features = Feature.enabled.count # Wrong: counts ALL features if completed_features < total_features issues << "incomplete_features" end
Why This Caused False Positives:
Features are league-specific (NHL has 9 features, PWHL has 2 features):
- Before fix: PWHL games with 2/2 features completed were compared against 11 total features (9 NHL + 2 PWHL)
- Result: PWHL games incorrectly flagged as incomplete (2 < 11) ❌
Solution Implemented:
Changed both locations to use league-specific feature counts:
-
Lines 454-468 - Iterate through games and check against league features:
incomplete_game_ids = [] final_games.includes(:league).find_each do |game| next unless game.league expected_features = Feature.enabled.for_league(game.league).count completed_features = game.game_features.where(status: "completed").count if completed_features < expected_features incomplete_game_ids << game.id end end -
Lines 485-492 - Use league-specific comparison:
if game.final? && game.league completed_features = game.game_features.where(status: "completed").count expected_features = Feature.enabled.for_league(game.league).count # Fixed! if completed_features < expected_features issues << "incomplete_features" end end
Testing Results:
✅ PWHL game: 2/2 features completed → NOT flagged as incomplete (correct!)
✅ NHL game: 9/9 features completed → NOT flagged as incomplete (correct!)
Files Modified:
-
app/controllers/api/v1/admin/seasons_controller.rb- Fixedfind_problem_gamesmethod
Impact:
- False positives eliminated
- Dashboard now accurately reflects game completion status
- Games only checked against their league's features
- Admin can now trust the "Problem Games" section for monitoring
Updated by William Lang about 2 months ago
- Status changed from Backlog to In Progress
Updated by William Lang about 2 months ago
- Status changed from In Progress to Done