@@ -44,9 +44,9 @@ class PerformanceController < Api::V1::BaseController
4444 # @param player_id [Integer] Player ID for individual stats (optional)
4545 # @return [JSON] Performance analytics data
4646 def index
47- # Use active players for team-wide stats (best performers, role breakdown, etc.)
48- # but validate player_id against ALL org players so that bench/trial/inactive
49- # players can still have their individual stats viewed .
47+ # Use all non-deleted org players for team-wide stats (best performers, role
48+ # breakdown, etc.) so that bench/trial/inactive players who have match stats
49+ # still appear in the leaderboard. Individual player stats use the same scope .
5050 all_org_players = organization_scoped ( Player ) . includes ( :organization )
5151 player_id = params [ :player_id ] . presence
5252
@@ -61,8 +61,7 @@ def index
6161 cache_key = performance_cache_key ( player_id )
6262 data = cache_response ( cache_key , expires_in : 15 . minutes ) do
6363 matches = apply_date_filters ( organization_scoped ( Match ) )
64- active_players = organization_scoped ( Player ) . includes ( :organization ) . active
65- service = PerformanceAnalyticsService . new ( matches , active_players )
64+ service = PerformanceAnalyticsService . new ( matches , all_org_players )
6665 service . calculate_performance_data ( player_id : player_id , all_players : all_org_players )
6766 end
6867
0 commit comments