Correct rank have wrong value

This commit is contained in:
Sebastien 2019-01-01 22:54:26 +01:00
parent 89f20e7644
commit fd14936565

View File

@ -165,19 +165,23 @@ public class UserStatsUtils {
List<UserStats> allStats = userStatsRepository.findByGuildId(guildId);
List<GuildStats> ranked = new ArrayList<>();
int i = 1;
for(UserStats stats : allStats){
String avatar = MainBot.jda.getUserById(stats.getUser().getJdaId()).getAvatarUrl();
GuildStats temp = new GuildStats(stats.getUser().getName(), i, avatar, stats.getVocalTime(), stats.getMessageCount(), stats.getApiCommandCount());
GuildStats temp = new GuildStats(stats.getUser().getName(), 0, avatar, stats.getVocalTime(), stats.getMessageCount(), stats.getApiCommandCount());
if(stats.getUser().getId().equals(userEntity.getId())){
selfGuildStats = temp;
}
ranked.add(temp);
i++;
}
ranked.sort((guildStats, t1) -> (int) (t1.total - guildStats.total));
int i = 1;
for(GuildStats stat : ranked){
stat.rank = i;
i++;
}
return new GuildStatsPack(ranked.indexOf(selfGuildStats) + 1 , selfGuildStats, ranked);
}