File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -511,8 +511,26 @@ const teamData = teamInfo.map(team => {
511511 return team ;
512512} ) ;
513513
514- // Create team rankings object
515- const rankings = createTeamRankings ( teamData , availablePeriods ) ;
514+ // Filter periods to only include those where some team has non-zero stats
515+ function periodHasTeamStats ( teams , period ) {
516+ return teams . some ( team => {
517+ const activeTotals = team [ period ] ?. ACTIVE_TOTALS ;
518+ if ( ! activeTotals ) return false ;
519+
520+ return ( activeTotals . goals || 0 ) > 0 ||
521+ ( activeTotals . assists || 0 ) > 0 ||
522+ ( activeTotals . toughness || 0 ) > 0 ||
523+ ( activeTotals . dstat || 0 ) > 0 ||
524+ ( activeTotals . gstat || 0 ) > 0 ;
525+ } ) ;
526+ }
527+
528+ const periodsWithStats = availablePeriods . filter ( period =>
529+ periodHasTeamStats ( teamData , period )
530+ ) ;
531+
532+ // Create team rankings object - only for periods with team stats
533+ const rankings = createTeamRankings ( teamData , periodsWithStats ) ;
516534
517- process . stdout . write ( JSON . stringify ( { teams : teamInfo , rankings, availablePeriods } ) ) ;
535+ process . stdout . write ( JSON . stringify ( { teams : teamInfo , rankings, availablePeriods : periodsWithStats } ) ) ;
518536//process.stdout.write(JSON.stringify(teamRankings));
You can’t perform that action at this time.
0 commit comments