mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-28 22:25:51 -05:00
Fix incorrect placement for in-progress SE/DE bracket
This commit is contained in:
@@ -114,7 +114,7 @@ export function tournamentStandings(tournament: Tournament): Standing[] {
|
||||
const standings = standingsToMergeable({
|
||||
alreadyIncludedTeamIds,
|
||||
standings: bracket.standings,
|
||||
teamsAboveCount: alreadyIncludedTeamIds.size,
|
||||
teamsAboveFromAnotherBracketsCount: alreadyIncludedTeamIds.size,
|
||||
});
|
||||
result.push(...standings);
|
||||
|
||||
@@ -134,11 +134,11 @@ function standingsToMergeable<
|
||||
>({
|
||||
alreadyIncludedTeamIds,
|
||||
standings,
|
||||
teamsAboveCount,
|
||||
teamsAboveFromAnotherBracketsCount,
|
||||
}: {
|
||||
alreadyIncludedTeamIds: Set<number>;
|
||||
standings: T[];
|
||||
teamsAboveCount: number;
|
||||
teamsAboveFromAnotherBracketsCount: number;
|
||||
}) {
|
||||
const result: T[] = [];
|
||||
|
||||
@@ -146,17 +146,24 @@ function standingsToMergeable<
|
||||
(standing) => !alreadyIncludedTeamIds.has(standing.team.id),
|
||||
);
|
||||
|
||||
let placement = teamsAboveCount + 1;
|
||||
// e.g. if standings start at 3rd place, this must mean there is 2 teams left to finish _this_ bracket
|
||||
const unfinishedTeamsCount = (standings.at(0)?.placement ?? 1) - 1;
|
||||
|
||||
let placement = 1;
|
||||
|
||||
for (const [i, standing] of filtered.entries()) {
|
||||
const placementChanged =
|
||||
i !== 0 && standing.placement !== filtered[i - 1].placement;
|
||||
|
||||
if (placementChanged) {
|
||||
placement = teamsAboveCount + i + 1;
|
||||
placement = i + 1;
|
||||
}
|
||||
|
||||
result.push({ ...standing, placement });
|
||||
result.push({
|
||||
...standing,
|
||||
placement:
|
||||
placement + teamsAboveFromAnotherBracketsCount + unfinishedTeamsCount,
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user