mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-28 11:01:28 +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 weekAgo = now - TimeAmount.WEEK.ms();
|
||||||
long monthAgo = now - TimeAmount.MONTH.ms();
|
long monthAgo = now - TimeAmount.MONTH.ms();
|
||||||
|
|
||||||
addValue("playersUniqueDay", AnalysisUtils.getUniqueJoinsPerDay(userSessions, dayAgo));
|
addValue("playersUniqueDay", AnalysisUtils.getUniquePlayers(userSessions, dayAgo));
|
||||||
addValue("playersUniqueWeek", AnalysisUtils.getUniqueJoinsPerDay(userSessions, weekAgo));
|
addValue("playersUniqueWeek", AnalysisUtils.getUniquePlayers(userSessions, weekAgo));
|
||||||
addValue("playersUniqueMonth", AnalysisUtils.getUniqueJoinsPerDay(userSessions, monthAgo));
|
addValue("playersUniqueMonth", AnalysisUtils.getUniquePlayers(userSessions, monthAgo));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void peakTimes(UUID serverUUID, long now, Database db) throws DBException {
|
private void peakTimes(UUID serverUUID, long now, Database db) throws DBException {
|
||||||
|
@ -33,6 +33,24 @@ public class AnalysisUtils {
|
|||||||
return newPlayers;
|
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) {
|
public static int getUniqueJoinsPerDay(Map<UUID, List<Session>> sessions, long after) {
|
||||||
Map<Integer, Set<UUID>> uniqueJoins = new HashMap<>();
|
Map<Integer, Set<UUID>> uniqueJoins = new HashMap<>();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user