Activity Pie Slices.

This commit is contained in:
Rsl1122 2017-09-05 12:36:39 +03:00
parent 864f50df62
commit fab0a0633a
3 changed files with 33 additions and 1 deletions

View File

@ -97,7 +97,8 @@ public class ActivityPart extends RawData {
);
addValue("activityColors", activityColors);
// addValue("activitydata", Arrays.toString(counts)); // TODO Check if needed
calculateActivityAmounts();
addValue("playersActive", counts[0]);
addValue("active", counts[0]);
addValue("inactive", counts[1]);
@ -105,6 +106,29 @@ public class ActivityPart extends RawData {
addValue("banned", counts[3]);
}
private void calculateActivityAmounts() {
for (Map.Entry<UUID, List<Session>> entry : joins.getSessions().entrySet()) {
UUID uuid = entry.getKey();
if (bans.contains(uuid)) {
continue;
}
List<Session> sessions = entry.getValue();
long lastSeen = AnalysisUtils.getLastSeen(sessions);
long playtime = AnalysisUtils.getTotalPlaytime(sessions);
int sessionCount = sessions.size();
if (sessionCount <= 1) {
addJoinedOnce(uuid);
continue;
}
boolean isActive = AnalysisUtils.isActive(MiscUtils.getTime(), lastSeen, playtime, sessionCount);
if (isActive) {
addActive(uuid);
} else {
addInActive(uuid);
}
}
}
public void addBans(Collection<UUID> uuids) {
bans.addAll(uuids);
}

View File

@ -74,6 +74,7 @@ public class InspectPageParser extends PageParser {
addValue("kickCount", timesKicked);
Map<String, Long> playtimeByServer = sessionsTable.getPlaytimeByServer(uuid);
// TODO Server preference pie
List<String> geolocations = db.getIpsTable().getGeolocations(uuid);
List<String> nicknames = db.getNicknamesTable().getNicknames(uuid).stream()

View File

@ -259,6 +259,13 @@ public class Analysis {
Log.debug("Analysis", "TPS Data Size: " + tpsData.size());
List<UserInfo> userInfo = db.getUserInfoTable().getServerUserInfo();
for (UserInfo user : userInfo) {
if (user.isBanned()) {
activity.addBan(user.getUuid());
}
}
Map<UUID, UserInfo> mappedUserInfo = userInfo.stream().collect(Collectors.toMap(UserInfo::getUuid, Function.identity()));
Map<UUID, Long> lastSeen = db.getSessionsTable().getLastSeenForAllPlayers();
for (Map.Entry<UUID, Long> entry : lastSeen.entrySet()) {