From ffefa65ca37eee6704efff0506620c0ae512796c Mon Sep 17 00:00:00 2001 From: rladydgn <39542757+rladydgn@users.noreply.github.com> Date: Wed, 6 Dec 2023 15:50:12 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=8C=80=EC=8B=9C=EB=B3=B4=EB=93=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EC=8B=9C=20=EC=84=9C=EB=B2=84=20=EC=A3=BD?= =?UTF-8?q?=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/dashboard/dashboard.controller.ts | 10 ++++++++-- be/algo-with-me-api/src/dashboard/dashboard.service.ts | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/be/algo-with-me-api/src/dashboard/dashboard.controller.ts b/be/algo-with-me-api/src/dashboard/dashboard.controller.ts index 7244568..e61e2a4 100644 --- a/be/algo-with-me-api/src/dashboard/dashboard.controller.ts +++ b/be/algo-with-me-api/src/dashboard/dashboard.controller.ts @@ -43,7 +43,7 @@ export class DashboardController { @ApiOperation({ summary: '[백엔드 테스트용] redis 대회 참가, 수정, 대시보드 조회 테스트' }) @Get('all/:competitionId') - async getDashboardTest(@Param('competitionId') competitionId: number = 5) { + async dashboardTest(@Param('competitionId') competitionId: number = 5) { await this.dashboardService.registerUserAtCompetition(competitionId, 'dhdgn@naver.com'); await this.dashboardService.registerUserAtCompetition(competitionId, 'qwer@naver.com'); await this.dashboardService.updateUserSubmission( @@ -53,7 +53,13 @@ export class DashboardController { RESULT.CORRECT, new Date(), ); - await this.dashboardService.getTop100DashboardRedis(5, 'dhdgn@naver.com'); + await this.dashboardService.getTop100DashboardRedis(competitionId, 'dhdgn@naver.com'); + } + + @ApiOperation({ summary: '[백엔드 테스트용] 대시보드 조회 테스트' }) + @Get('test/:competitionId') + async getDashboardTest(@Param('competitionId') competitionId: number = 5) { + return await this.dashboardService.getTop100DashboardRedis(competitionId, 'dhdgn@naver.com'); } @ApiOperation({ summary: '대회 종료 이후 대시보드 조회' }) diff --git a/be/algo-with-me-api/src/dashboard/dashboard.service.ts b/be/algo-with-me-api/src/dashboard/dashboard.service.ts index 8d8edfa..102c015 100644 --- a/be/algo-with-me-api/src/dashboard/dashboard.service.ts +++ b/be/algo-with-me-api/src/dashboard/dashboard.service.ts @@ -165,6 +165,9 @@ export class DashboardService { rankings.push({ email: scores[i], score: scores[i + 1] }); emails.push(scoreKey + ':' + scores[i]); } + + if (emails.length === 0) return { rankings, emails }; + const problems = await this.redis.mget(emails); this.logger.debug(problems); for (const [idx, ranking] of rankings.entries()) {