From: Daniel Karbach Date: Wed, 23 Mar 2022 15:46:32 +0000 (+0100) Subject: fix scoring bug when non-runners are participating X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;h=c9f99f9ad642f6c387b36b640c3c17cdfe58988a;p=alttp.git fix scoring bug when non-runners are participating --- diff --git a/resources/js/helpers/Tournament.js b/resources/js/helpers/Tournament.js index 792b593..38750e7 100644 --- a/resources/js/helpers/Tournament.js +++ b/resources/js/helpers/Tournament.js @@ -2,11 +2,13 @@ import Participant from './Participant'; import Round from './Round'; export const calculateScores = tournament => { - const scores = getRunners(tournament).map(participant => ({ participant, score: 0 })); + const runners = getRunners(tournament); + const scores = runners.map(participant => ({ participant, score: 0 })); + if (!scores.length) return scores; if (!tournament.rounds || !tournament.rounds.length) return scores; tournament.rounds.forEach(round => { const filtered = Participant - .sortByResult(tournament.participants, round) + .sortByResult(runners, round) .map(p => ({ participant: p, result: Participant.findResult(p, round) })) .filter(r => r.result && (r.result.time || r.result.forfeit)) .reverse();