use of com.djrapitops.plan.utilities.comparators.SessionStartComparator in project Plan by plan-player-analytics.
the class JSONFactory method networkSessionsAsJSONMap.
public List<Map<String, Object>> networkSessionsAsJSONMap() {
Database db = dbSystem.getDatabase();
Integer perPageLimit = config.get(DisplaySettings.SESSIONS_PER_PAGE);
List<FinishedSession> sessions = db.query(SessionQueries.fetchLatestSessions(perPageLimit));
// Add online sessions
if (serverInfo.getServer().isProxy()) {
addActiveSessions(sessions);
sessions.sort(new SessionStartComparator());
while (true) {
int size = sessions.size();
if (size <= perPageLimit)
break;
// Remove last until it fits.
sessions.remove(size - 1);
}
}
List<Map<String, Object>> sessionMaps = new SessionsMutator(sessions).toPlayerNameJSONMaps(graphs, config.getWorldAliasSettings(), formatters);
// Add network_server property so that sessions have a server page link
sessionMaps.forEach(map -> map.put("network_server", map.get("server_name")));
return sessionMaps;
}
use of com.djrapitops.plan.utilities.comparators.SessionStartComparator in project Plan by plan-player-analytics.
the class JSONFactory method serverSessionsAsJSONMap.
public List<Map<String, Object>> serverSessionsAsJSONMap(ServerUUID serverUUID) {
Database db = dbSystem.getDatabase();
Integer perPageLimit = config.get(DisplaySettings.SESSIONS_PER_PAGE);
List<FinishedSession> sessions = db.query(SessionQueries.fetchLatestSessionsOfServer(serverUUID, perPageLimit));
// Add online sessions
if (serverUUID.equals(serverInfo.getServerUUID())) {
addActiveSessions(sessions);
sessions.sort(new SessionStartComparator());
while (true) {
int size = sessions.size();
if (size <= perPageLimit)
break;
// Remove last until it fits.
sessions.remove(size - 1);
}
}
return new SessionsMutator(sessions).toPlayerNameJSONMaps(graphs, config.getWorldAliasSettings(), formatters);
}
Aggregations