Add ranking, need to do mobile view
This commit is contained in:
parent
f0d4b865b1
commit
89f20e7644
@ -2,6 +2,7 @@ package net.Broken.Tools.UserManager.Stats;
|
||||
|
||||
public class GuildStats{
|
||||
public String userName;
|
||||
public int rank;
|
||||
public String avatarUrl;
|
||||
|
||||
public long voiceTime;
|
||||
@ -19,13 +20,13 @@ public class GuildStats{
|
||||
public GuildStats() {
|
||||
}
|
||||
|
||||
public GuildStats(String userName, String avatarUrl, long voiceTime, long messageCount, long apiCount) {
|
||||
public GuildStats(String userName, int rank, String avatarUrl, long voiceTime, long messageCount, long apiCount) {
|
||||
this.userName = userName;
|
||||
this.avatarUrl = avatarUrl;
|
||||
this.voiceTime = voiceTime;
|
||||
this.messageCount = messageCount;
|
||||
this.apiCount = apiCount;
|
||||
|
||||
this.rank = rank;
|
||||
|
||||
voiceXp = (long) (this.voiceTime * UserStatsUtils.XP_PER_VOICE_TIME);
|
||||
messageXp = (long) (this.messageCount * UserStatsUtils.XP_PER_MESSAGE);
|
||||
|
@ -165,13 +165,16 @@ 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(), avatar, stats.getVocalTime(), stats.getMessageCount(), stats.getApiCommandCount());
|
||||
GuildStats temp = new GuildStats(stats.getUser().getName(), i, 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));
|
||||
|
||||
|
@ -24,6 +24,11 @@
|
||||
font-size: 15px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
td span{
|
||||
color: #fbcf40;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@ -42,7 +47,7 @@
|
||||
<main>
|
||||
<!--/*@thymesVar id="stack" type="net.Broken.Tools.UserManager.Stats.GuildStatsPack"*/-->
|
||||
<div class="row">
|
||||
<div class="card-panel col m6 offset-m3 s10 offset-s1 grey darken-4 white-text">
|
||||
<div class="card-panel col l6 offset-l3 m10 offset-m1 s10 offset-s1 grey darken-4 white-text">
|
||||
<div class="row" style="margin-bottom: 0">
|
||||
<div class="col s12 center" style="margin-top: 10px">
|
||||
<img class="circle" th:src="${stack.selfStats.avatarUrl}"
|
||||
@ -52,8 +57,8 @@
|
||||
<h4 style="font-weight: bold; margin: 0;" th:text="${stack.selfStats.userName}"></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s6 center">
|
||||
<div class="row" style="margin-bottom: 0">
|
||||
<div class="col m6 s12 center">
|
||||
<table class="centered">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -72,7 +77,7 @@
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="col s6 center">
|
||||
<div class="col m6 s12 center">
|
||||
<table class="centered">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -94,7 +99,7 @@
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col s6 center">
|
||||
<div class="col m6 s12 center">
|
||||
<table class="centered">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -105,9 +110,12 @@
|
||||
<tr>
|
||||
<td>
|
||||
<h4 style="font-weight: bold; margin: 0">
|
||||
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stack.selfStats.voiceTime).get(0)}" th:remove="tag"></span> <span>H</span>
|
||||
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stack.selfStats.voiceTime).get(1)}" th:remove="tag"></span> <span>M</span>
|
||||
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stack.selfStats.voiceTime).get(2)}" th:remove="tag"></span> <span>S</span>
|
||||
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stack.selfStats.voiceTime).get(0)}"
|
||||
th:remove="tag"></span> <span>H</span>
|
||||
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stack.selfStats.voiceTime).get(1)}"
|
||||
th:remove="tag"></span> <span>M</span>
|
||||
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stack.selfStats.voiceTime).get(2)}"
|
||||
th:remove="tag"></span> <span>S</span>
|
||||
</h4>
|
||||
</td>
|
||||
</tr>
|
||||
@ -115,7 +123,7 @@
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="col s6 center">
|
||||
<div class="col m6 s12 center">
|
||||
<table class="centered">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -137,6 +145,50 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col l6 offset-l3 m10 offset-m1 hide-on-small-and-down card-panel grey darken-4 white-text">
|
||||
<h3 class="center"><b>Ranking</b></h3>
|
||||
|
||||
<table class="centered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Rank</th>
|
||||
<th></th>
|
||||
<th>Name</th>
|
||||
<th>Vocal Time</th>
|
||||
<th>Message Count</th>
|
||||
<th>Total XP</th>
|
||||
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<th:block th:each="stat : ${stack.ranking}">
|
||||
<tr>
|
||||
<td th:text="${stat.rank}"></td>
|
||||
<td><img th:src="${stat.avatarUrl}" class="circle" style="max-height: 50px"/> </td>
|
||||
<td th:text="${stat.userName}"></td>
|
||||
<td> <span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stat.voiceTime).get(0)}"
|
||||
th:remove="tag"></span> <span>H</span>
|
||||
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stat.voiceTime).get(1)}"
|
||||
th:remove="tag"></span> <span>M</span>
|
||||
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stat.voiceTime).get(2)}"
|
||||
th:remove="tag"></span> <span>S</span></td>
|
||||
<td th:text="${stat.messageCount}"></td>
|
||||
<td th:text="${stat.total}"></td>
|
||||
|
||||
</tr>
|
||||
</th:block>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
<footer class="page-footer" style="padding: 0">
|
||||
|
Loading…
Reference in New Issue
Block a user