From 2dbe5c589b7875012c77fe530c67805098e4c360 Mon Sep 17 00:00:00 2001 From: Ly Tuan Kiet Date: Tue, 10 Dec 2024 16:57:04 +0700 Subject: [PATCH] refactor: simplify quiz retrieval logic by removing unnecessary schedule validation - Removed the requirement for 'scheduleId' in the quiz retrieval process, streamlining the logic and improving code clarity. - Consolidated the quiz retrieval query to enhance maintainability while ensuring it still functions correctly with the existing data structure. - Updated the .gitignore to clarify the purpose of the 'pothos.generated.ts' file, improving project documentation. --- .gitignore | 2 +- src/Quiz/quiz.schema.ts | 23 +++++++---------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 7a7c2ce..6ed2cf8 100644 --- a/.gitignore +++ b/.gitignore @@ -131,5 +131,5 @@ dist .pnp.* -# pothos generated +# Pothos generated types declaration pothos.generated.ts \ No newline at end of file diff --git a/src/Quiz/quiz.schema.ts b/src/Quiz/quiz.schema.ts index edaa32b..18c879f 100644 --- a/src/Quiz/quiz.schema.ts +++ b/src/Quiz/quiz.schema.ts @@ -213,22 +213,13 @@ export class QuizSchema extends PothosSchema { if (!centerMentor) { throw new Error('Center mentor not found') } - if (args.scheduleId) { - const schedule = await this.prisma.schedule.findUnique({ - where: { id: args.scheduleId }, - }) - if (!schedule) { - throw new Error('Schedule not found') - } - return await this.prisma.quiz.findMany({ - ...query, - where: { - serviceId: args.serviceId, - centerMentorId: centerMentor.mentorId, - }, - }) - } - throw new Error('Schedule ID is required') + return await this.prisma.quiz.findMany({ + ...query, + where: { + serviceId: args.serviceId, + centerMentorId: centerMentor.mentorId, + }, + }) } }, }),