Skip to content
Snippets Groups Projects
Commit f9ad7d05 authored by PASQUIER-TROIANO AZZO's avatar PASQUIER-TROIANO AZZO
Browse files

hotfix: fix a bug which was not fixed

parent c8be3836
Branches
2 merge requests!97hotfix: fix a bug which was not fixed,!95V4.0
Pipeline #325589 passed with stages
in 1 minute and 33 seconds
......@@ -6,7 +6,8 @@ import { FullQuestion } from 'src/utils/FullQuestion';
@Injectable()
export class RunRepositoryOnDb implements RunRepository {
constructor(private readonly prisma: PrismaService) {}
constructor(private readonly prisma: PrismaService) {
}
async create(
runID: string,
......@@ -27,18 +28,29 @@ export class RunRepositoryOnDb implements RunRepository {
}
async getRunsByUser(userId: number) {
const runs = await this.prisma.$queryRaw`
SELECT r.*
FROM Run r
INNER JOIN Quiz q ON r.quizId = q.id
WHERE r.quizUserId = ${userId}
AND r.questionIndex < q.questionCount;
`;
const runs = await this.prisma.run.findMany({
where: {
quizUserId: userId,
},
include: {
quiz: {
select: {
category: true,
difficulty: true,
name: true,
questionCount: true,
description: true,
},
},
},
});
console.log(runs);
return runs;
// Filtrer les `Run` avec `questionIndex < questionCount`
return runs.filter((run) => run.questionIndex < run.quiz.questionCount);
}
async getQuestion(runId: string) {
// Récupérer la `Run` pour obtenir l'index de la question actuelle et le quizId
const run = await this.prisma.run.findUnique({
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment