mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Fixes longest world time calculation #690
This commit is contained in:
parent
53851bb6da
commit
151d09f284
@ -154,11 +154,11 @@ public class Session extends DataContainer implements DateHolder {
|
||||
}
|
||||
|
||||
public void setWorldTimes(WorldTimes worldTimes) {
|
||||
putRawData(SessionKeys.WORLD_TIMES, worldTimes);
|
||||
this.worldTimes = worldTimes;
|
||||
}
|
||||
|
||||
public void setPlayerKills(List<PlayerKill> playerKills) {
|
||||
putRawData(SessionKeys.PLAYER_KILLS, playerKills);
|
||||
this.playerKills = playerKills;
|
||||
}
|
||||
|
||||
public boolean isFetchedFromDB() {
|
||||
@ -231,7 +231,6 @@ public class Session extends DataContainer implements DateHolder {
|
||||
}
|
||||
|
||||
Map<String, Long> playtimePerAlias = worldTimes.getPlaytimePerAlias();
|
||||
long total = worldTimes.getTotal();
|
||||
|
||||
long longest = 0;
|
||||
String theWorld = "-";
|
||||
@ -244,6 +243,11 @@ public class Session extends DataContainer implements DateHolder {
|
||||
}
|
||||
}
|
||||
|
||||
long total = worldTimes.getTotal();
|
||||
// Prevent arithmetic error if 0
|
||||
if (total <= 0) {
|
||||
total = -1;
|
||||
}
|
||||
double quotient = longest * 1.0 / total;
|
||||
|
||||
return theWorld + " (" + Formatters.percentage().apply(quotient) + ")";
|
||||
|
@ -170,8 +170,11 @@ public class WorldTimes {
|
||||
}
|
||||
|
||||
public Map<String, Long> getPlaytimePerAlias() {
|
||||
Map<String, Long> playtimePerWorld = getWorldTimes() // WorldTimes Map<String, GMTimes>
|
||||
.entrySet().stream()
|
||||
if (times.isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
Map<String, Long> playtimePerWorld = times.entrySet().stream() // WorldTimes Map<String, GMTimes>
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
entry -> entry.getValue().getTotal() // GMTimes.getTotal
|
||||
|
Loading…
Reference in New Issue
Block a user