Browse Source

fix ranks

master
nicolas-arnaud 2 years ago
parent
commit
14651041ff
  1. 15
      back/volume/src/users/users.service.ts

15
back/volume/src/users/users.service.ts

@ -128,18 +128,17 @@ export class UsersService {
async getLeaderboard (): Promise<User[]> { async getLeaderboard (): Promise<User[]> {
const leaderboard = await this.usersRepository.find({ const leaderboard = await this.usersRepository.find({
order: { order: {
winrate: 'ASC' winrate: 'DESC'
} }
}) })
const ret = leaderboard.filter((user) => user.matchs !== 0) let r = 1
let r = 0 let ret: Array<User> = []
ret.forEach((usr) => { for (let usr of leaderboard.filter((user) => user.matchs !== 0)) {
usr.rank = r++ usr.rank = r++
this.usersRepository.save(usr).catch((err) => { await this.usersRepository.save(usr)
console.log(err) ret.push(usr)
})
usr.socketKey = '' usr.socketKey = ''
}) }
return ret return ret
} }

Loading…
Cancel
Save