From 68978a5c83e4cbda35a741018d4a6ae8e6db243e Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Fri, 15 Nov 2024 23:16:50 +0200 Subject: [PATCH] Add isFinalized to api/tournament/:id --- app/features/api-public/routes/tournament.$id.ts | 8 +++++++- app/features/api-public/schema.ts | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/features/api-public/routes/tournament.$id.ts b/app/features/api-public/routes/tournament.$id.ts index b559b9b23..b71006f95 100644 --- a/app/features/api-public/routes/tournament.$id.ts +++ b/app/features/api-public/routes/tournament.$id.ts @@ -33,11 +33,16 @@ export const loader = async ({ params, request }: LoaderFunctionArgs) => { "CalendarEventDate.eventId", "CalendarEvent.id", ) - .select(({ eb }) => [ + .select(({ eb, exists, selectFrom }) => [ "CalendarEvent.name", "CalendarEvent.organizationId", "CalendarEventDate.startTime", "Tournament.settings", + exists( + selectFrom("TournamentResult") + .where("TournamentResult.tournamentId", "=", id) + .select("TournamentResult.tournamentId"), + ).as("isFinalized"), eb .selectFrom("UserSubmittedImage") .select(["UserSubmittedImage.url"]) @@ -80,6 +85,7 @@ export const loader = async ({ params, request }: LoaderFunctionArgs) => { type: bp.type, })), organizationId: tournament.organizationId, + isFinalized: Boolean(tournament.isFinalized), }; return await cors(request, json(result)); diff --git a/app/features/api-public/schema.ts b/app/features/api-public/schema.ts index 3fa599e69..048945add 100644 --- a/app/features/api-public/schema.ts +++ b/app/features/api-public/schema.ts @@ -85,6 +85,8 @@ export interface GetTournamentResponse { }; brackets: TournamentBracket[]; organizationId: number | null; + /** Has the tournament concluded (results added to user profiles & no editing possible anymore) */ + isFinalized: boolean; } /** GET /api/tournament/{tournamentId}/teams */