use of com.djrapitops.plan.storage.database.Database in project Plan by plan-player-analytics.
the class GraphJSONCreator method hourlyUniqueAndNewGraphJSON.
public String hourlyUniqueAndNewGraphJSON(ServerUUID serverUUID) {
Database db = dbSystem.getDatabase();
LineGraphFactory lineGraphs = graphs.line();
long now = System.currentTimeMillis();
long weekAgo = now - TimeUnit.DAYS.toMillis(7L);
int timeZoneOffset = config.getTimeZone().getOffset(now);
NavigableMap<Long, Integer> uniquePerDay = db.query(PlayerCountQueries.hourlyUniquePlayerCounts(weekAgo, now, timeZoneOffset, serverUUID));
NavigableMap<Long, Integer> newPerDay = db.query(PlayerCountQueries.newPlayerCounts(weekAgo, now, timeZoneOffset, serverUUID));
return createUniqueAndNewJSON(lineGraphs, uniquePerDay, newPerDay, TimeUnit.HOURS.toMillis(1L));
}
use of com.djrapitops.plan.storage.database.Database in project Plan by plan-player-analytics.
the class GraphJSONCreator method serverWorldPieJSONAsMap.
public Map<String, Object> serverWorldPieJSONAsMap(ServerUUID serverUUID) {
Database db = dbSystem.getDatabase();
WorldTimes worldTimes = db.query(WorldTimesQueries.fetchServerTotalWorldTimes(serverUUID));
WorldPie worldPie = graphs.pie().worldPie(worldTimes);
return Maps.builder(String.class, Object.class).put("world_series", worldPie.getSlices()).put("gm_series", worldPie.toHighChartsDrillDownMaps()).build();
}
use of com.djrapitops.plan.storage.database.Database in project Plan by plan-player-analytics.
the class GraphJSONCreator method hourlyUniqueAndNewGraphJSON.
public String hourlyUniqueAndNewGraphJSON() {
Database db = dbSystem.getDatabase();
LineGraphFactory lineGraphs = graphs.line();
long now = System.currentTimeMillis();
long weekAgo = now - TimeUnit.DAYS.toMillis(7L);
int timeZoneOffset = config.getTimeZone().getOffset(now);
NavigableMap<Long, Integer> uniquePerDay = db.query(PlayerCountQueries.hourlyUniquePlayerCounts(weekAgo, now, timeZoneOffset));
NavigableMap<Long, Integer> newPerDay = db.query(PlayerCountQueries.hourlyNewPlayerCounts(weekAgo, now, timeZoneOffset));
return createUniqueAndNewJSON(lineGraphs, uniquePerDay, newPerDay, TimeUnit.HOURS.toMillis(1L));
}
use of com.djrapitops.plan.storage.database.Database in project Plan by plan-player-analytics.
the class NetworkOverviewJSONCreator method createNumbersMap.
private Map<String, Object> createNumbersMap() {
Database db = dbSystem.getDatabase();
long now = System.currentTimeMillis();
long twoDaysAgo = now - TimeUnit.DAYS.toMillis(2L);
Long playtimeThreshold = config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD);
Map<String, Object> numbers = new HashMap<>();
Integer userCount = db.query(PlayerCountQueries.newPlayerCount(0L, now));
numbers.put("total_players", userCount);
numbers.put("regular_players", db.query(NetworkActivityIndexQueries.fetchRegularPlayerCount(now, playtimeThreshold)));
numbers.put("online_players", serverSensor.getOnlinePlayerCount());
ServerUUID serverUUID = serverInfo.getServerUUID();
Optional<DateObj<Integer>> lastPeak = db.query(TPSQueries.fetchPeakPlayerCount(serverUUID, twoDaysAgo));
Optional<DateObj<Integer>> allTimePeak = db.query(TPSQueries.fetchAllTimePeakPlayerCount(serverUUID));
numbers.put("last_peak_date", lastPeak.map(year).orElse("-"));
numbers.put("last_peak_players", lastPeak.map(dateObj -> dateObj.getValue().toString()).orElse("-"));
numbers.put("best_peak_date", allTimePeak.map(year).orElse("-"));
numbers.put("best_peak_players", allTimePeak.map(dateObj -> dateObj.getValue().toString()).orElse("-"));
Long totalPlaytime = db.query(SessionQueries.playtime(0L, now));
numbers.put("playtime", timeAmount.apply(totalPlaytime));
numbers.put("player_playtime", userCount != 0 ? timeAmount.apply(totalPlaytime / userCount) : "-");
Long sessionCount = db.query(SessionQueries.sessionCount(0L, now));
numbers.put("sessions", sessionCount);
numbers.put("session_length_avg", sessionCount != 0 ? timeAmount.apply(totalPlaytime / sessionCount) : "-");
numbers.put("current_uptime", serverUptimeCalculator.getServerUptimeMillis(serverUUID).map(timeAmount).orElse(locale.getString(GenericLang.UNAVAILABLE)));
return numbers;
}
use of com.djrapitops.plan.storage.database.Database in project Plan by plan-player-analytics.
the class PluginBooleanGroupFilter method getMatchingUUIDs.
@Override
public Set<UUID> getMatchingUUIDs(InputFilterDto query) {
Map<PluginBooleanOption, SelectedBoolean> selectedBooleanOptions = new HashMap<>();
for (String selected : getSelected(query)) {
String[] optionAndBoolean = StringUtils.split(selected, ":", 2);
PluginBooleanOption pluginBooleanOption = PluginBooleanOption.parse(optionAndBoolean[0].trim());
String selectedBoolean = optionAndBoolean[1].trim().toUpperCase();
selectedBooleanOptions.computeIfPresent(pluginBooleanOption, (key, existing) -> SelectedBoolean.BOTH);
selectedBooleanOptions.computeIfAbsent(pluginBooleanOption, key -> SelectedBoolean.valueOf(selectedBoolean));
}
Database db = dbSystem.getDatabase();
Map<String, ServerUUID> namesToUUIDs = db.query(ServerQueries.fetchServerNamesToUUIDs());
return db.query(playersInGroups(selectedBooleanOptions, namesToUUIDs));
}
Aggregations