Skip to content

Commit 6c3f341

Browse files
committed
Only include a stats period if it has any stats in it.
1 parent 6599eca commit 6c3f341

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

src/data/standings.json.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff 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));

0 commit comments

Comments
 (0)