Merge branch 'main' of https://github.com/orosmatthew/bw-hspc-contest-env
This commit is contained in:
commit
a4c0258d3f
@ -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[]
|
||||||
}
|
}
|
||||||
|
20
web/src/routes/api/team/[session]/+server.ts
Normal file
20
web/src/routes/api/team/[session]/+server.ts
Normal 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;
|
Loading…
Reference in New Issue
Block a user