From 431e478f21055c755b7396a26427a0556ec7b450 Mon Sep 17 00:00:00 2001 From: Ly Tuan Kiet Date: Tue, 10 Dec 2024 16:37:53 +0700 Subject: [PATCH] refactor: streamline quiz schema formatting and improve readability - Reformatted the quiz schema for consistent indentation and spacing, enhancing overall code clarity. - Consolidated the random index calculation into a single line for improved readability. - Maintained existing functionality while ensuring the code adheres to style guidelines for better maintainability. --- src/Quiz/quiz.schema.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Quiz/quiz.schema.ts b/src/Quiz/quiz.schema.ts index a804f19..f90b430 100644 --- a/src/Quiz/quiz.schema.ts +++ b/src/Quiz/quiz.schema.ts @@ -75,7 +75,7 @@ export class QuizSchema extends PothosSchema { quizAttempt() { return this.builder.prismaObject('QuizAttempt', { fields: (t) => ({ - id: t.exposeID('id'), + id: t.exposeID('id'), quizId: t.exposeID('quizId'), quiz: t.relation('quiz'), userId: t.exposeID('userId'), @@ -195,9 +195,7 @@ export class QuizSchema extends PothosSchema { }, }) // get amount of questions using nrOfQuestions and random index based on random - const randomIndex = quizzes.length > 0 - ? Math.floor(random * quizzes.length) - : 0 + const randomIndex = quizzes.length > 0 ? Math.floor(random * quizzes.length) : 0 const nrOfQuestions = quizzes[0]?.nrOfQuestions ?? 1 const result = quizzes.slice(randomIndex, randomIndex + nrOfQuestions) return result