mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-14 20:21:45 +01:00
Fixes Network page displaying odd Unique player numbers (#518)
This commit is contained in:
parent
13e948c1b4
commit
70130f9629
@ -81,9 +81,9 @@ public class NetworkPage extends Page {
|
||||
long weekAgo = now - TimeAmount.WEEK.ms();
|
||||
long monthAgo = now - TimeAmount.MONTH.ms();
|
||||
|
||||
addValue("playersUniqueDay", AnalysisUtils.getUniqueJoinsPerDay(userSessions, dayAgo));
|
||||
addValue("playersUniqueWeek", AnalysisUtils.getUniqueJoinsPerDay(userSessions, weekAgo));
|
||||
addValue("playersUniqueMonth", AnalysisUtils.getUniqueJoinsPerDay(userSessions, monthAgo));
|
||||
addValue("playersUniqueDay", AnalysisUtils.getUniquePlayers(userSessions, dayAgo));
|
||||
addValue("playersUniqueWeek", AnalysisUtils.getUniquePlayers(userSessions, weekAgo));
|
||||
addValue("playersUniqueMonth", AnalysisUtils.getUniquePlayers(userSessions, monthAgo));
|
||||
}
|
||||
|
||||
private void peakTimes(UUID serverUUID, long now, Database db) throws DBException {
|
||||
|
@ -33,6 +33,24 @@ public class AnalysisUtils {
|
||||
return newPlayers;
|
||||
}
|
||||
|
||||
public static int getUniquePlayers(Map<UUID, List<Session>> sessions, long after) {
|
||||
Set<UUID> uuids = new HashSet<>();
|
||||
|
||||
for (Map.Entry<UUID, List<Session>> entry : sessions.entrySet()) {
|
||||
UUID uuid = entry.getKey();
|
||||
for (Session session : entry.getValue()) {
|
||||
if (session.getSessionStart() < after) {
|
||||
continue;
|
||||
} else {
|
||||
uuids.add(uuid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return uuids.size();
|
||||
}
|
||||
|
||||
public static int getUniqueJoinsPerDay(Map<UUID, List<Session>> sessions, long after) {
|
||||
Map<Integer, Set<UUID>> uniqueJoins = new HashMap<>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user