From b77f70a22d9525927edd22c82f85aa27bea02fc5 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Wed, 16 Apr 2025 12:28:05 +0300 Subject: [PATCH] Add points to tournament-match endpoint Closes #2191 --- .../api-public/routes/tournament-match.$id.ts | 31 ++++++++++++------- app/features/api-public/schema.ts | 2 ++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/features/api-public/routes/tournament-match.$id.ts b/app/features/api-public/routes/tournament-match.$id.ts index 0217e6ff9..a37ad7186 100644 --- a/app/features/api-public/routes/tournament-match.$id.ts +++ b/app/features/api-public/routes/tournament-match.$id.ts @@ -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, }; }); }; diff --git a/app/features/api-public/schema.ts b/app/features/api-public/schema.ts index e6a272335..304b02296 100644 --- a/app/features/api-public/schema.ts +++ b/app/features/api-public/schema.ts @@ -337,6 +337,8 @@ type MapListMap = { source: number | "DEFAULT" | "TIEBREAKER" | "BOTH" | "TO" | "COUNTERPICK"; winnerTeamId: number | null; participatedUserIds: Array | 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 = {