-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make seed script pull from a data-export endpoint
- Loading branch information
1 parent
9207ec8
commit 2d2a1fb
Showing
11 changed files
with
128 additions
and
456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import prisma from "@/prisma/global-prisma-client"; | ||
import { Prisma } from "@prisma/client"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export type DataExport = { | ||
algorithms: Prisma.AlgorithmCreateManyInput[]; | ||
algorithmsForCase: Prisma.AlgorithmsForCaseCreateManyInput[]; | ||
cases: Prisma.CaseCreateManyInput[]; | ||
methods: Prisma.MethodCreateManyInput[]; | ||
puzzles: Prisma.PuzzleCreateManyInput[]; | ||
sets: { | ||
id: string; | ||
name: string; | ||
slug: string; | ||
puzzleId: string; | ||
visualizationId: string; | ||
cases: { | ||
id: string; | ||
name: string; | ||
setup: string; | ||
puzzleId: string; | ||
}[]; | ||
methods: { | ||
id: string; | ||
name: string; | ||
slug: string; | ||
puzzleId: string; | ||
visualizationId: string; | ||
}[]; | ||
}[]; | ||
visualizations: Prisma.VisualizationCreateManyInput[]; | ||
}; | ||
|
||
export async function GET(request: Request) { | ||
const algorithms = prisma.algorithm.findMany(); | ||
const algorithmsForCase = prisma.algorithmsForCase.findMany(); | ||
const cases = prisma.case.findMany(); | ||
const methods = prisma.method.findMany(); | ||
const puzzles = prisma.puzzle.findMany(); | ||
const sets = prisma.set.findMany({ | ||
include: { | ||
cases: true, | ||
methods: true, | ||
}, | ||
}); | ||
const visualizations = prisma.visualization.findMany(); | ||
|
||
const data = await Promise.all([ | ||
algorithms, | ||
algorithmsForCase, | ||
cases, | ||
methods, | ||
puzzles, | ||
sets, | ||
visualizations, | ||
]); | ||
|
||
return NextResponse.json( | ||
{ | ||
algorithms: data[0], | ||
algorithmsForCase: data[1], | ||
cases: data[2], | ||
methods: data[3], | ||
puzzles: data[4], | ||
sets: data[5], | ||
visualizations: data[6], | ||
}, | ||
{ status: 200 } | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.