Add points to tournament-match endpoint Closes #2191

This commit is contained in:
Kalle
2025-04-16 12:28:05 +03:00
parent eb95870b8b
commit b77f70a22d
2 changed files with 21 additions and 12 deletions

View File

@@ -59,6 +59,8 @@ export const loader = async ({ params, request }: LoaderFunctionArgs) => {
"TournamentMatchGameResult.mode",
"TournamentMatchGameResult.winnerTeamId",
"TournamentMatchGameResult.source",
"TournamentMatchGameResult.opponentOnePoints",
"TournamentMatchGameResult.opponentTwoPoints",
jsonArrayFrom(
innerEb
.selectFrom("TournamentMatchGameResultParticipant")
@@ -97,17 +99,21 @@ export const loader = async ({ params, request }: LoaderFunctionArgs) => {
match.opponentOne.result === "win" ||
match.opponentTwo.result === "win"
) {
return match.playedMapList.map((map) => ({
return match.playedMapList.map((playedMap) => ({
map: {
mode: map.mode,
mode: playedMap.mode,
stage: {
id: map.stageId,
name: t(`game-misc:STAGE_${map.stageId}`),
id: playedMap.stageId,
name: t(`game-misc:STAGE_${playedMap.stageId}`),
},
},
participatedUserIds: map.participants.map((p) => p.userId),
winnerTeamId: map.winnerTeamId,
source: parseSource(map.source),
participatedUserIds: playedMap.participants.map((p) => p.userId),
winnerTeamId: playedMap.winnerTeamId,
source: parseSource(playedMap.source),
points:
playedMap.opponentOnePoints && playedMap.opponentTwoPoints
? [playedMap.opponentOnePoints, playedMap.opponentTwoPoints]
: null,
}));
}
@@ -123,18 +129,19 @@ export const loader = async ({ params, request }: LoaderFunctionArgs) => {
mapPickingStyle: match.mapPickingStyle,
maps: match.maps,
pickBanEvents,
}).map((map) => {
}).map((mapListMap) => {
return {
map: {
mode: map.mode,
mode: mapListMap.mode,
stage: {
id: map.stageId,
name: t(`game-misc:STAGE_${map.stageId}`),
id: mapListMap.stageId,
name: t(`game-misc:STAGE_${mapListMap.stageId}`),
},
},
participatedUserIds: null,
winnerTeamId: null,
source: map.source,
source: mapListMap.source,
points: null,
};
});
};

View File

@@ -337,6 +337,8 @@ type MapListMap = {
source: number | "DEFAULT" | "TIEBREAKER" | "BOTH" | "TO" | "COUNTERPICK";
winnerTeamId: number | null;
participatedUserIds: Array<number> | null;
/** (round robin only) points of the match used for tiebreaker purposes. e.g. [100, 0] indicates a knockout. */
points: [number, number] | null;
};
type TournamentMatchTeam = {