Skip to content

fix(be): fix contest leaderboard ranking malfunction#3419

Open
zero1177 wants to merge 5 commits intomainfrom
t2552-modify-contest-statistics-leaderboard
Open

fix(be): fix contest leaderboard ranking malfunction#3419
zero1177 wants to merge 5 commits intomainfrom
t2552-modify-contest-statistics-leaderboard

Conversation

@zero1177
Copy link
Copy Markdown
Contributor

@zero1177 zero1177 commented Feb 10, 2026

Description

Contest 리더보드 순위 표시가 잘못된 문제 수정

contest 7 기준으로 테스트

contestProblem 문제는 problemId 5,6,7,8 총 4개이고 (점수 각각 50, 60, 70, 80)

user02~user08 까지 7명의 user가 참여했다는 가정

  • solvedProblemCount가 동일할 경우, penalty가 적은 user가 상위 rank임을 테스트 완료
  • solvedProblemCount, penalty까지 모두 동일할 경우 동점 처리 확인

ex) 공동 4등 2명이면, 다음은 6등

const testData = [
{
// user02 (2등) 3솔
scores: [50, 60, 70, 0],
penalties: [30, 30, 40, 0]
},
{
// user03 (1등) 4솔
scores: [50, 60, 70, 80],
penalties: [15, 100, 55, 200]
},
{
// user04 (3등) 3솔
scores: [0, 60, 70, 80],
penalties: [0, 150, 20, 300]
},
{
// user05 (6등) 2솔
scores: [0, 0, 70, 80],
penalties: [0, 0, 150, 100]
},
{
//user06 (7등) 1솔
scores: [0, 0, 70, 0],
penalties: [0, 0, 150, 0]
},
{
//user07 (공동 4등) 2솔
scores: [50, 60, 0, 0], //110
penalties: [20, 35, 0, 0] //55
},
{
//user08 (공동 4등) 2솔
scores: [0, 60, 70, 0], //130
penalties: [0, 35, 20, 0] //55
}
]

Before submitting the PR, please make sure you do the following

@zero1177 zero1177 requested a review from hjkim24 February 10, 2026 15:08
@zero1177 zero1177 self-assigned this Feb 10, 2026
@zero1177 zero1177 added ⛳️ team-backend 🍊squad-유자차 스쿼드 유자차 작업물입니다 labels Feb 10, 2026
@skkuding-bot
Copy link
Copy Markdown

skkuding-bot bot commented Feb 10, 2026

Syncing Preview App Succeeded

Application: frontend
Revision: 2e9ff4cc85cd6d061fdc1c3c9755bfcc3712cd32
Health Status: Healthy

Open Preview | View in Argo CD

@hjkim24
Copy link
Copy Markdown
Contributor

hjkim24 commented Mar 25, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the contest leaderboard calculation logic in ContestService, introducing custom sorting and ranking based on solved problems and penalties, and adds new seeding data for contestId7 to test these changes. The review highlights a performance regression in ContestService due to sequential database queries that should be parallelized using Promise.all. Additionally, the new ranking logic in ContestService does not correctly handle ties, and a related comment is misleading. In prisma/seed.ts, the newly created contest7Records are not included in the function's return value, and there's a typo in a comment describing the number of solved problems for a test user.

Comment thread apps/backend/apps/client/src/contest/contest.service.ts Outdated
Comment thread apps/backend/apps/client/src/contest/contest.service.ts Outdated
Comment thread apps/backend/apps/client/src/contest/contest.service.ts Outdated
Comment thread apps/backend/prisma/seed.ts Outdated
Comment thread apps/backend/prisma/seed.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍊squad-유자차 스쿼드 유자차 작업물입니다 ⛳️ team-backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants