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.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -131,5 +131,5 @@ dist
|
|||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
|
|
||||||
# pothos generated
|
# Pothos generated types declaration
|
||||||
pothos.generated.ts
|
pothos.generated.ts
|
||||||
@@ -213,22 +213,13 @@ export class QuizSchema extends PothosSchema {
|
|||||||
if (!centerMentor) {
|
if (!centerMentor) {
|
||||||
throw new Error('Center mentor not found')
|
throw new Error('Center mentor not found')
|
||||||
}
|
}
|
||||||
if (args.scheduleId) {
|
return await this.prisma.quiz.findMany({
|
||||||
const schedule = await this.prisma.schedule.findUnique({
|
...query,
|
||||||
where: { id: args.scheduleId },
|
where: {
|
||||||
})
|
serviceId: args.serviceId,
|
||||||
if (!schedule) {
|
centerMentorId: centerMentor.mentorId,
|
||||||
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')
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user