Skip to content

Commit

Permalink
Compute which round(s) to show ourselves
Browse files Browse the repository at this point in the history
The new NHL API returns the current round as, for example, 3 even when all series from round 2 haven't been completed. This adds detection of series which haven't been played all the way out and sets that as the current round.
  • Loading branch information
parnic committed May 20, 2024
1 parent 8983660 commit 69d5dd8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,13 @@ module.exports = NodeHelper.create({
if (season.mode === 3 || games.length === 0) {

const playoffData = await this.fetchPlayoffs();
const playoffSeries = this.computePlayoffDetails(playoffData).filter(s => s.round >= playoffData.currentRound);
let currentRound = playoffData ? playoffData.currentRound : 0;
if (playoffData && playoffData.rounds) {
const activeRounds = playoffData.rounds.filter(round => round.series.some(series => series.bottomSeed.wins < series.neededToWin && series.topSeed.wins < series.neededToWin));
const activeRoundNumbers = activeRounds.map(round => round.roundNumber);
currentRound = Math.min(...activeRoundNumbers);
}
const playoffSeries = this.computePlayoffDetails(playoffData).filter(s => s.round >= currentRound);

this.sendSocketNotification('PLAYOFFS', playoffSeries);
}
Expand Down

0 comments on commit 69d5dd8

Please sign in to comment.