|
@ -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 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|