fix: removed unused database fields & fix prisma errors
This commit is contained in:
parent
da3a9df402
commit
b47b59f4cd
|
@ -8,7 +8,6 @@ export async function getGrade(testId: number, userId: number) {
|
||||||
grade: true,
|
grade: true,
|
||||||
id: true,
|
id: true,
|
||||||
testId: true,
|
testId: true,
|
||||||
note: true,
|
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
|
@ -24,7 +23,6 @@ export async function addGrade(testId: number, userId: number, grade: number, no
|
||||||
const newGrade = await prisma.grade.create({
|
const newGrade = await prisma.grade.create({
|
||||||
data: {
|
data: {
|
||||||
grade: grade,
|
grade: grade,
|
||||||
note: note,
|
|
||||||
testId: testId,
|
testId: testId,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ export async function getActiveTest(date: Date) {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isPassed: true,
|
|
||||||
testOf: {
|
testOf: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
@ -30,7 +29,6 @@ export async function getActiveTest(date: Date) {
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isPassed: false,
|
|
||||||
testOn: new Date(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + (date.getDate().toString().length === 1 ? '0' + date.getDate() : date.getDate())),
|
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: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isPassed: true,
|
|
||||||
testOf: {
|
testOf: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
@ -54,7 +51,6 @@ export async function getActiveTestWithGrade(date: Date, userId: number) {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
grade: true,
|
grade: true,
|
||||||
note: true,
|
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
},
|
},
|
||||||
take: 1,
|
take: 1,
|
||||||
|
@ -67,7 +63,6 @@ export async function getActiveTestWithGrade(date: Date, userId: number) {
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isPassed: false,
|
|
||||||
testOn: new Date(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + (date.getDate().toString().length === 1 ? '0' + date.getDate() : date.getDate())),
|
testOn: new Date(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + (date.getDate().toString().length === 1 ? '0' + date.getDate() : date.getDate())),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,10 +8,9 @@ export default async function Dashboard() {
|
||||||
console.log(authSession);
|
console.log(authSession);
|
||||||
if (!authSession) return redirect('/');
|
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 activeTests = tests.filter((test) => test.isActive);
|
||||||
const passedTests = tests.filter((test) => test.isPassed);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -24,12 +24,11 @@ export default function Page({ params }: { params: { id: string } }) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
featchResults(testId);
|
featchResults(testId);
|
||||||
|
setTimeout(() => {
|
||||||
|
featchResults(testId);
|
||||||
|
}, 5000);
|
||||||
}, [testId]);
|
}, [testId]);
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
featchResults(testId);
|
|
||||||
}, 5000);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={'p-4 md:p-12 w-full h-screen bg-black flex flex-col justify-between gap-y-4'}>
|
<div className={'p-4 md:p-12 w-full h-screen bg-black flex flex-col justify-between gap-y-4'}>
|
||||||
<Image src={logo} alt={'Logo'} width={100} height={200} className={'mx-auto w-full md:w-[400px]'} />
|
<Image src={logo} alt={'Logo'} width={100} height={200} className={'mx-auto w-full md:w-[400px]'} />
|
||||||
|
|
|
@ -14,27 +14,25 @@ model Users {
|
||||||
firstName String
|
firstName String
|
||||||
lastName String
|
lastName String
|
||||||
isTeacher Boolean @default(false)
|
isTeacher Boolean @default(false)
|
||||||
|
isAdmin Boolean @default(false)
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
grades Grade[]
|
grades Grade[]
|
||||||
test Test?
|
test Test?
|
||||||
}
|
}
|
||||||
|
|
||||||
model Test {
|
model Test {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
testOfId Int @unique
|
testOfId Int @unique
|
||||||
testOn DateTime @db.Date
|
testOn DateTime @db.Date
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
testOf Users @relation(fields: [testOfId], references: [id])
|
testOf Users @relation(fields: [testOfId], references: [id])
|
||||||
grades Grade[]
|
grades Grade[]
|
||||||
isActive Boolean @default(false)
|
isActive Boolean @default(false)
|
||||||
isPassed Boolean @default(false)
|
|
||||||
teacherGrade Float?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model Grade {
|
model Grade {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
userId Int
|
userId Int
|
||||||
note String?
|
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
grade Float
|
grade Float
|
||||||
testId Int
|
testId Int
|
||||||
|
|
Loading…
Reference in New Issue