fix(be): fix contest leaderboard ranking malfunction#3419
fix(be): fix contest leaderboard ranking malfunction#3419
Conversation
|
✅ Syncing Preview App Succeeded Application: |
|
/gemini review |
There was a problem hiding this comment.
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.
…& penalty and add seed data
Description
Contest 리더보드 순위 표시가 잘못된 문제 수정
contest 7 기준으로 테스트
contestProblem 문제는 problemId 5,6,7,8 총 4개이고 (점수 각각 50, 60, 70, 80)
user02~user08 까지 7명의 user가 참여했다는 가정
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
fixes #123).