This commit is contained in:
orosmatthew 2023-05-07 11:01:28 -04:00
commit a4c0258d3f
2 changed files with 32 additions and 9 deletions

View File

@ -11,7 +11,7 @@ model User {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
username String @unique username String @unique
password String password String
Submission Session[] sessions Session[]
} }
model Session { model Session {
@ -47,7 +47,7 @@ model Problem {
sampleOutput String sampleOutput String
realInput String realInput String
realOutput String realOutput String
Submission Submission[] submissions Submission[]
contests Contest[] @relation("ProblemContestRelation") contests Contest[] @relation("ProblemContestRelation")
} }
@ -66,6 +66,8 @@ model ActiveTeam {
team Team @relation(fields: [teamId], references: [id]) team Team @relation(fields: [teamId], references: [id])
sessionToken String? @unique sessionToken String? @unique
sessionCreatedAt DateTime? sessionCreatedAt DateTime?
contestId Int
contest Contest @relation(fields: [contestId], references: [id])
} }
model Contest { model Contest {
@ -73,4 +75,5 @@ model Contest {
name String name String
teams Team[] @relation("TeamContestRelation") teams Team[] @relation("TeamContestRelation")
problems Problem[] @relation("ProblemContestRelation") problems Problem[] @relation("ProblemContestRelation")
activeTeams ActiveTeam[]
} }

View File

@ -0,0 +1,20 @@
import type { RequestHandler } from './$types';
import { error, json } from '@sveltejs/kit';
import { db } from '$lib/server/prisma';
export const GET = (async ({ params }) => {
const session = params.session;
const activeTeam = await db.activeTeam.findUnique({
where: { sessionToken: session }
});
if (!activeTeam) {
return json({ success: false });
}
return json({
success: true,
data: {
teamId: activeTeam.teamId,
contestId: activeTeam.contestId
}
});
}) satisfies RequestHandler;