mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
feat(types): add problem and testcase details types with prisma include
This commit is contained in:
parent
a02335b255
commit
5698a6b81f
@ -2,9 +2,31 @@ import prisma from "@/lib/prisma";
|
|||||||
|
|
||||||
type ThenArg<T> = T extends PromiseLike<infer U> ? U : T;
|
type ThenArg<T> = T extends PromiseLike<infer U> ? U : T;
|
||||||
|
|
||||||
export async function getTestcaseWithData() {
|
export async function getAllProblems() {
|
||||||
const testcases = await prisma.testcase.findMany({ include: { data: true } });
|
return await prisma.problem.findMany({
|
||||||
return testcases;
|
include: {
|
||||||
|
templates: true,
|
||||||
|
testcases: {
|
||||||
|
include: {
|
||||||
|
data: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TestcaseWithData = ThenArg<ReturnType<typeof getTestcaseWithData>>;
|
export type ProblemWithDetails = ThenArg<
|
||||||
|
ReturnType<typeof getAllProblems>
|
||||||
|
>[number];
|
||||||
|
|
||||||
|
export async function getAllTestcases() {
|
||||||
|
return await prisma.testcase.findMany({
|
||||||
|
include: {
|
||||||
|
data: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TestcaseWithDetails = ThenArg<
|
||||||
|
ReturnType<typeof getAllTestcases>
|
||||||
|
>;
|
||||||
|
Loading…
Reference in New Issue
Block a user