Skip to content

Commit

Permalink
#81 Modify recent quiz completions to be consistent with what we want…
Browse files Browse the repository at this point in the history
… to return for recent uploads
  • Loading branch information
danielemery committed Nov 26, 2023
1 parent 40931a1 commit 5cab74a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/quiz/quiz.persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export class QuizPersistence {
},
quiz: {
select: {
id: true,
date: true,
type: true,
},
Expand Down
2 changes: 1 addition & 1 deletion src/quiz/quiz.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ describe('quiz', () => {
{
completionDate: new Date('2023-01-01'),
score: 12,
participants: [{ email: '[email protected]', name: 'Quiz Master' }],
completedBy: [{ email: '[email protected]', name: 'Quiz Master' }],
quizDate: new Date('2022-12-12'),
quizType: 'SHARK',
},
Expand Down
3 changes: 2 additions & 1 deletion src/quiz/quiz.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,12 @@ export class QuizService {
async getRecentQuizCompletions(first = 20) {
const recent = await this.#persistence.getRecentQuizCompletions({ limit: first });
return recent.map((completion) => ({
quizId: completion.quiz.id,
quizType: completion.quiz.type,
quizDate: completion.quiz.date,
completionDate: completion.completedAt,
score: completion.score.toNumber(),
participants: completion.completedBy.map((user) => ({
completedBy: completion.completedBy.map((user) => ({
name: user.user.name,
email: user.user.email,
})),
Expand Down

0 comments on commit 5cab74a

Please sign in to comment.