Fix tournament result participants count for many starting brackets
Some checks are pending
E2E Tests / e2e (push) Waiting to run
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run

This commit is contained in:
Kalle
2025-11-05 19:55:11 +02:00
parent 559ff23750
commit b111992acd
2 changed files with 68 additions and 1 deletions

View File

@@ -526,9 +526,15 @@ function tournamentResults({
? getBracketProgressionLabel(team.startingBracketIdx, progression)
: null;
const divisionParticipantCount =
div !== null
? teams.filter((t) => t.startingBracketIdx === team.startingBracketIdx)
.length
: participantCount;
for (const player of standing.team.members) {
result.push({
participantCount,
participantCount: divisionParticipantCount,
placement: standing.placement,
tournamentTeamId: standing.team.id,
userId: player.userId,

View File

@@ -721,4 +721,65 @@ describe("tournamentSummary()", () => {
expect(team1Results.every((r) => r.div === "Division 1")).toBeTruthy();
expect(team2Results.every((r) => r.div === "Division 2")).toBeTruthy();
});
test("participantCount is correct for multi-division tournaments", () => {
const summary = summarize({
teamsWithStartingBrackets: [
{ id: 1, startingBracketIdx: 0 },
{ id: 2, startingBracketIdx: 1 },
{ id: 3, startingBracketIdx: 0 },
{ id: 4, startingBracketIdx: 1 },
],
progression: [
{
name: "Division 1",
type: "single_elimination",
settings: {},
requiresCheckIn: false,
},
{
name: "Division 2",
type: "single_elimination",
settings: {},
requiresCheckIn: false,
},
],
finalStandings: [
{
placement: 1,
team: createTeam(1, [1, 2, 3, 4]),
},
{
placement: 1,
team: createTeam(2, [5, 6, 7, 8]),
},
{
placement: 2,
team: createTeam(3, [9, 10, 11, 12]),
},
{
placement: 2,
team: createTeam(4, [13, 14, 15, 16]),
},
],
});
const team1Results = summary.tournamentResults.filter(
(r) => r.tournamentTeamId === 1,
);
const team2Results = summary.tournamentResults.filter(
(r) => r.tournamentTeamId === 2,
);
const team3Results = summary.tournamentResults.filter(
(r) => r.tournamentTeamId === 3,
);
const team4Results = summary.tournamentResults.filter(
(r) => r.tournamentTeamId === 4,
);
expect(team1Results.every((r) => r.participantCount === 2)).toBeTruthy();
expect(team2Results.every((r) => r.participantCount === 2)).toBeTruthy();
expect(team3Results.every((r) => r.participantCount === 2)).toBeTruthy();
expect(team4Results.every((r) => r.participantCount === 2)).toBeTruthy();
});
});