Prevented possible ArithmeticExceptions

This commit is contained in:
Rsl1122 2017-12-02 19:55:51 +02:00
parent a71f444bf8
commit c665f128d7
2 changed files with 9 additions and 1 deletions

View File

@ -92,7 +92,13 @@ public class PlayerProfile implements OfflinePlayer {
long threeWeeksAgo = date - 3L * week;
long activePlayThreshold = Settings.ACTIVE_PLAY_THRESHOLD.getNumber() * TimeAmount.MINUTE.ms();
if (activePlayThreshold <= 0) {
activePlayThreshold = 1;
}
int activeLoginThreshold = Settings.ACTIVE_LOGIN_THRESHOLD.getNumber();
if (activeLoginThreshold <= 0) {
activeLoginThreshold = 1;
}
List<Session> sessionsWeek = getSessions(weekAgo, date).collect(Collectors.toList());
List<Session> sessionsWeek2 = getSessions(twoWeeksAgo, weekAgo).collect(Collectors.toList());

View File

@ -169,7 +169,9 @@ public class ServerProfile {
}
public double getNewPlayersPerDay(long after, long before) {
return getNewPlayers(after, before) * 1.0 / AnalysisUtils.getNumberOfDaysBetween(after, before);
long days = AnalysisUtils.getNumberOfDaysBetween(after, before);
long newPlayers = getNewPlayers(after, before);
return days == 0 ? newPlayers : newPlayers * 1.0 / days;
}
public Stream<PlayerProfile> getPlayersWhoPlayedBetween(long after, long before) {