Project

General

Profile

Actions

Bug #4

closed

Admin season dashboard incorrectly marking games with 'incomplete features' in problem games section

Added by William Lang about 2 months ago. Updated about 2 months ago.

Status:
Done
Priority:
Low
Assignee:
Start date:
12/30/2025
Due date:
% Done:

100%

Estimated time:

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

  1. Feature completion logic: Check how game.game_features completion status is being evaluated
  2. Preseason games: Are preseason games being incorrectly flagged? (We skip preseason data collection)
  3. Feature definitions: Are all expected features properly defined for each league?
  4. Race conditions: Could there be timing issues where features are marked complete after the dashboard queries?
  5. Query logic: Review the SQL/ActiveRecord query that identifies "problem games"

Related Code

Likely locations:

  • Admin dashboard controller/view code
  • GameFeature model and completion logic
  • Season/Game associations with features
  • Feature definition in League model

Reproduction Steps

  1. Navigate to admin season dashboard
  2. Look at "Problem Games" section
  3. Observe games marked with "incomplete features"
  4. Check those games' game_features records
  5. 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.

Actions #1

Updated by William Lang about 2 months ago

Starting investigation into the problem games logic in admin season dashboard.

Actions #2

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:

  1. Line 458 - Query to find incomplete games:

    .having("...", Feature.enabled.count)  # Wrong: counts ALL features
    
  2. 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:

  1. 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
    
  2. 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 - Fixed find_problem_games method

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
Actions #3

Updated by William Lang about 2 months ago

  • % Done changed from 0 to 100
Actions #4

Updated by William Lang about 2 months ago

  • Assignee set to William Lang
Actions #5

Updated by William Lang about 2 months ago

  • Status changed from Backlog to In Progress
Actions #6

Updated by William Lang about 2 months ago

  • Status changed from In Progress to Done
Actions

Also available in: Atom PDF