From 14651041ff9ae566feb6277c4926d4d112d8d0da Mon Sep 17 00:00:00 2001 From: nicolas-arnaud Date: Thu, 16 Mar 2023 15:53:21 +0100 Subject: [PATCH] fix ranks --- back/volume/src/users/users.service.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/back/volume/src/users/users.service.ts b/back/volume/src/users/users.service.ts index b194dfd..2edf18e 100644 --- a/back/volume/src/users/users.service.ts +++ b/back/volume/src/users/users.service.ts @@ -128,18 +128,17 @@ export class UsersService { async getLeaderboard (): Promise { const leaderboard = await this.usersRepository.find({ order: { - winrate: 'ASC' + winrate: 'DESC' } }) - const ret = leaderboard.filter((user) => user.matchs !== 0) - let r = 0 - ret.forEach((usr) => { + let r = 1 + let ret: Array = [] + for (let usr of leaderboard.filter((user) => user.matchs !== 0)) { usr.rank = r++ - this.usersRepository.save(usr).catch((err) => { - console.log(err) - }) + await this.usersRepository.save(usr) + ret.push(usr) usr.socketKey = '' - }) + } return ret }