Skip to content

Commit

Permalink
fix: 대시보드 조회시 서버 죽는 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
rladydgn committed Dec 6, 2023
1 parent 7722bce commit ffefa65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions be/algo-with-me-api/src/dashboard/dashboard.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, '[email protected]');
await this.dashboardService.registerUserAtCompetition(competitionId, '[email protected]');
await this.dashboardService.updateUserSubmission(
Expand All @@ -53,7 +53,13 @@ export class DashboardController {
RESULT.CORRECT,
new Date(),
);
await this.dashboardService.getTop100DashboardRedis(5, '[email protected]');
await this.dashboardService.getTop100DashboardRedis(competitionId, '[email protected]');
}

@ApiOperation({ summary: '[백엔드 테스트용] 대시보드 조회 테스트' })
@Get('test/:competitionId')
async getDashboardTest(@Param('competitionId') competitionId: number = 5) {
return await this.dashboardService.getTop100DashboardRedis(competitionId, '[email protected]');
}

@ApiOperation({ summary: '대회 종료 이후 대시보드 조회' })
Expand Down
3 changes: 3 additions & 0 deletions be/algo-with-me-api/src/dashboard/dashboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit ffefa65

Please sign in to comment.