Skip to content

Commit 75e2e8e

Browse files
author
robot
committed
feat: rank
1 parent f3a4ef6 commit 75e2e8e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

routes/dailyProblem.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ for (const [login, solution] of Object.entries(mySolutions)) {
5757

5858
const rankings = A.sort((a, b) => b.count - a.count);
5959

60+
for (let i = 0; i < rankings.length; i++) {
61+
if (i > 0 && rankings[i].count === rankings[i - 1].count) {
62+
rankings[i].rank = rankings[i - 1].rank;
63+
} else {
64+
rankings[i].rank = i + 1;
65+
}
66+
}
67+
6068
router.get("/api/v1/daily-problem/ranking", async (ctx) => {
6169
ctx.body = success(rankings);
6270
});

0 commit comments

Comments
 (0)