From d65144bb8e6bb02c410f19801a57702851dc8456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=84=ED=98=84=EB=AF=BC?= <77275989+joyjhm@users.noreply.github.com> Date: Thu, 5 Dec 2024 17:15:25 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=80=B4=EC=A6=88=EC=85=8B=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=EC=8B=9C=20=EC=B6=94=EC=B2=9C=20=ED=80=B4=EC=A6=88?= =?UTF-8?q?=EA=B0=80=20=EC=95=9E=EC=9C=BC=EB=A1=9C=20=EC=98=A4=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/backend/src/quiz/quiz.service.ts | 14 +------------- .../src/quiz/repository/quiz-set.repository.ts | 15 +-------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/apps/backend/src/quiz/quiz.service.ts b/apps/backend/src/quiz/quiz.service.ts index a191163cc..a04abb4ac 100644 --- a/apps/backend/src/quiz/quiz.service.ts +++ b/apps/backend/src/quiz/quiz.service.ts @@ -54,7 +54,7 @@ export class QuizService { } async deleteQuizSet(quizSetId: number) { - const quiz = await this.findQuizSet(quizSetId); + const quizSet = await this.findQuizSet(quizSetId); await this.quizSetRepository.delete({ id: quizSetId }); } @@ -80,10 +80,6 @@ export class QuizService { async searchQuizSet(searchQuery: SearchQuizSetRequestDTO) { const { name, page, size } = searchQuery; - if (!name) { - return this.findDefaultQuizSet(page, size); - } - const [quizSets, count] = await Promise.all([ this.quizSetRepository.searchByName(name, page, size), this.quizSetRepository.countByName(name), @@ -93,12 +89,4 @@ export class QuizService { return { quizSetDetails, total: count, currentPage: page }; } - private async findDefaultQuizSet(page: number, size: number) { - const [quizSets, count] = await Promise.all([ - this.quizSetRepository.findByRecommend(page, size), - this.quizSetRepository.countByRecommend(), - ]); - const quizSetDetails = quizSets.map(QuizSetDetails.from); - return { quizSetDetails, total: count, currentPage: page }; - } } diff --git a/apps/backend/src/quiz/repository/quiz-set.repository.ts b/apps/backend/src/quiz/repository/quiz-set.repository.ts index 66ee5425f..4275e55fc 100644 --- a/apps/backend/src/quiz/repository/quiz-set.repository.ts +++ b/apps/backend/src/quiz/repository/quiz-set.repository.ts @@ -11,7 +11,7 @@ export class QuizSetRepository extends Repository { searchByName(name: string, page: number, pageSize: number) { return this.find({ where: {name: ILike(`${name}%`)}, - order: {createAt: 'desc'}, + order: {recommended: 'DESC', createAt: 'desc' }, skip: (page - 1) * pageSize, take: pageSize, }); @@ -20,17 +20,4 @@ export class QuizSetRepository extends Repository { countByName(name: string) { return this.count({ where: { name: ILike(`${name}%`) } }); } - - countByRecommend() { - return this.count({where: {recommended: true}}); - } - - findByRecommend(page: number, pageSize: number) { - return this.find({ - where: {recommended: true}, - order: {createAt: 'desc'}, - skip: (page - 1) * pageSize, - take: pageSize, - }) - } }