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

@ -8,10 +8,10 @@ datasource db {
}
model User {
id Int @id @default(autoincrement())
username String @unique
password String
Submission Session[]
id Int @id @default(autoincrement())
username String @unique
password String
sessions Session[]
}
model Session {
@ -47,7 +47,7 @@ model Problem {
sampleOutput String
realInput String
realOutput String
Submission Submission[]
submissions Submission[]
contests Contest[] @relation("ProblemContestRelation")
}
@ -66,11 +66,14 @@ model ActiveTeam {
team Team @relation(fields: [teamId], references: [id])
sessionToken String? @unique
sessionCreatedAt DateTime?
contestId Int
contest Contest @relation(fields: [contestId], references: [id])
}
model Contest {
id Int @id @default(autoincrement())
name String
teams Team[] @relation("TeamContestRelation")
problems Problem[] @relation("ProblemContestRelation")
id Int @id @default(autoincrement())
name String
teams Team[] @relation("TeamContestRelation")
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;