mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-16 05:01:43 +01:00
Prevented possible ArithmeticExceptions
This commit is contained in:
parent
a71f444bf8
commit
c665f128d7
@ -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());
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user