mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 07:37:55 -05:00
Fix loser source matches logic + add tests
This commit is contained in:
30
app/services/bracket.test.ts
Normal file
30
app/services/bracket.test.ts
Normal file
File diff suppressed because one or more lines are too long
@@ -108,7 +108,7 @@ function modifyRounds(
|
||||
});
|
||||
}
|
||||
|
||||
function addLoserTeamSourceInfo({
|
||||
export function addLoserTeamSourceInfo({
|
||||
winners,
|
||||
losers,
|
||||
}: {
|
||||
@@ -129,13 +129,7 @@ function addLoserTeamSourceInfo({
|
||||
.flatMap((round) => round.matches)
|
||||
.reduce((acc: Map<string, number[]>, match) => {
|
||||
if (!match.loserDestinationMatchId) return acc;
|
||||
|
||||
acc.set(
|
||||
match.loserDestinationMatchId,
|
||||
(acc.get(match.loserDestinationMatchId) ?? [])
|
||||
.concat(match.number)
|
||||
.sort((a, b) => a - b)
|
||||
);
|
||||
if (match.number === 0) return acc;
|
||||
|
||||
const nextMatchAfterByeId = nextMatchAfterBye(
|
||||
match.loserDestinationMatchId
|
||||
@@ -147,6 +141,13 @@ function addLoserTeamSourceInfo({
|
||||
.concat(match.number)
|
||||
.sort((a, b) => a - b)
|
||||
);
|
||||
} else {
|
||||
acc.set(
|
||||
match.loserDestinationMatchId,
|
||||
(acc.get(match.loserDestinationMatchId) ?? [])
|
||||
.concat(match.number)
|
||||
.sort((a, b) => a - b)
|
||||
);
|
||||
}
|
||||
|
||||
return acc;
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
"uvu": "^0.5.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "16.3.1",
|
||||
"node": ">=16",
|
||||
"npm": ">=8"
|
||||
},
|
||||
"sideEffects": false,
|
||||
|
||||
Reference in New Issue
Block a user