Docker compose con variabili d'ambiente
This commit is contained in:
@@ -13,6 +13,17 @@ class UsersService {
|
||||
return await this.usersRepository.findById(id);
|
||||
}
|
||||
|
||||
async getCurrentUserWithRank(id) {
|
||||
const user = await this.usersRepository.findById(id);
|
||||
const userJson = user.toJSON ? user.toJSON() : { ...user };
|
||||
const totalUsers = await this.usersRepository.count();
|
||||
const usersAbove = await this.usersRepository.countWithScoreAbove(userJson.score, id);
|
||||
const rankPercentile = totalUsers > 1
|
||||
? Math.max(1, Math.round((usersAbove / totalUsers) * 100))
|
||||
: 1;
|
||||
return { ...userJson, rankPercentile };
|
||||
}
|
||||
|
||||
async searchUsers(query, excludeUserId) {
|
||||
return await this.usersRepository.search(query, excludeUserId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user