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();