feat: enhance QuizSchema with improved filtering for quiz attempts
- Refactored the query for retrieving quiz attempts to utilize an AND condition for better filtering based on center mentor ID and additional filters. - Improved the structure of the query to enhance readability and maintainability. These changes enhance the data retrieval capabilities of the Quiz feature, ensuring more precise and efficient access to quiz attempts based on user and quiz criteria.
This commit is contained in:
@@ -314,12 +314,14 @@ export class QuizSchema extends PothosSchema {
|
|||||||
return await this.prisma.quizAttempt.findMany({
|
return await this.prisma.quizAttempt.findMany({
|
||||||
...query,
|
...query,
|
||||||
where: {
|
where: {
|
||||||
...args.filter,
|
AND: [
|
||||||
|
{
|
||||||
quiz: {
|
quiz: {
|
||||||
centerMentorId: centerMentor.mentorId,
|
centerMentorId: centerMentor.mentorId,
|
||||||
},
|
},
|
||||||
...(args.quizId ? [{ quizId: args.quizId }] : []),
|
},
|
||||||
...(args.userId ? [{ quizId: args.userId }] : []),
|
...(args.filter ? [args.filter] : []),
|
||||||
|
],
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: 'desc',
|
createdAt: 'desc',
|
||||||
|
|||||||
Reference in New Issue
Block a user