fix: removed unused database fields & fix prisma errors

This commit is contained in:
Elie Baier 2023-12-20 10:20:21 +01:00
parent da3a9df402
commit b47b59f4cd
5 changed files with 12 additions and 23 deletions

View File

@ -8,7 +8,6 @@ export async function getGrade(testId: number, userId: number) {
grade: true,
id: true,
testId: true,
note: true,
createdAt: true,
},
where: {
@ -24,7 +23,6 @@ export async function addGrade(testId: number, userId: number, grade: number, no
const newGrade = await prisma.grade.create({
data: {
grade: grade,
note: note,
testId: testId,
userId: userId,
}

View File

@ -16,7 +16,6 @@ export async function getActiveTest(date: Date) {
select: {
id: true,
isActive: true,
isPassed: true,
testOf: {
select: {
id: true,
@ -30,7 +29,6 @@ export async function getActiveTest(date: Date) {
},
where: {
isActive: true,
isPassed: false,
testOn: new Date(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + (date.getDate().toString().length === 1 ? '0' + date.getDate() : date.getDate())),
},
});
@ -41,7 +39,6 @@ export async function getActiveTestWithGrade(date: Date, userId: number) {
select: {
id: true,
isActive: true,
isPassed: true,
testOf: {
select: {
id: true,
@ -54,7 +51,6 @@ export async function getActiveTestWithGrade(date: Date, userId: number) {
select: {
id: true,
grade: true,
note: true,
createdAt: true,
},
take: 1,
@ -67,7 +63,6 @@ export async function getActiveTestWithGrade(date: Date, userId: number) {
},
where: {
isActive: true,
isPassed: false,
testOn: new Date(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + (date.getDate().toString().length === 1 ? '0' + date.getDate() : date.getDate())),
},
});

View File

@ -8,10 +8,9 @@ export default async function Dashboard() {
console.log(authSession);
if (!authSession) return redirect('/');
const tests = await prisma.test.findMany({ select: { isActive: true, isPassed: true, id: true, testOf: { select: { id: true, firstName: true, lastName: true, isTeacher: true } } } });
const tests = await prisma.test.findMany({ select: { isActive: true, id: true, testOf: { select: { id: true, firstName: true, lastName: true, isTeacher: true } } } });
const activeTests = tests.filter((test) => test.isActive);
const passedTests = tests.filter((test) => test.isPassed);
return (
<div>

View File

@ -24,11 +24,10 @@ export default function Page({ params }: { params: { id: string } }) {
useEffect(() => {
featchResults(testId);
}, [testId]);
setTimeout(() => {
featchResults(testId);
}, 5000);
}, [testId]);
return (
<div className={'p-4 md:p-12 w-full h-screen bg-black flex flex-col justify-between gap-y-4'}>

View File

@ -14,6 +14,7 @@ model Users {
firstName String
lastName String
isTeacher Boolean @default(false)
isAdmin Boolean @default(false)
createdAt DateTime @default(now())
grades Grade[]
test Test?
@ -27,14 +28,11 @@ model Test {
testOf Users @relation(fields: [testOfId], references: [id])
grades Grade[]
isActive Boolean @default(false)
isPassed Boolean @default(false)
teacherGrade Float?
}
model Grade {
id Int @id @default(autoincrement())
userId Int
note String?
createdAt DateTime @default(now())
grade Float
testId Int