Search in sources :

Example 81 with Database

use of com.djrapitops.plan.storage.database.Database in project Plan by plan-player-analytics.

the class ServerPlaceHolders method register.

@Override
public void register(PlanPlaceholders placeholders) {
    Formatter<Double> decimals = formatters.decimals();
    Formatter<Double> percentage = formatters.percentage();
    Database database = dbSystem.getDatabase();
    placeholders.registerStatic("server_players_registered_total", parameters -> database.query(PlayerCountQueries.newPlayerCount(0, now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_players_registered_day", parameters -> database.query(PlayerCountQueries.newPlayerCount(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_players_registered_week", parameters -> database.query(PlayerCountQueries.newPlayerCount(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_players_registered_month", parameters -> database.query(PlayerCountQueries.newPlayerCount(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("network_players_registered_total", parameters -> database.query(PlayerCountQueries.newPlayerCount(0, now())));
    placeholders.registerStatic("network_players_registered_day", parameters -> database.query(PlayerCountQueries.newPlayerCount(dayAgo(), now())));
    placeholders.registerStatic("network_players_registered_week", parameters -> database.query(PlayerCountQueries.newPlayerCount(weekAgo(), now())));
    placeholders.registerStatic("network_players_registered_month", parameters -> database.query(PlayerCountQueries.newPlayerCount(monthAgo(), now())));
    placeholders.registerStatic("server_players_unique_total", parameters -> database.query(PlayerCountQueries.newPlayerCount(0, now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_players_unique_day", parameters -> database.query(PlayerCountQueries.uniquePlayerCount(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_players_unique_week", parameters -> database.query(PlayerCountQueries.uniquePlayerCount(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_players_unique_month", parameters -> database.query(PlayerCountQueries.uniquePlayerCount(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("network_players_unique_total", parameters -> database.query(PlayerCountQueries.uniquePlayerCount(0, now())));
    placeholders.registerStatic("network_players_unique_day", parameters -> database.query(PlayerCountQueries.uniquePlayerCount(dayAgo(), now())));
    placeholders.registerStatic("network_players_unique_week", parameters -> database.query(PlayerCountQueries.uniquePlayerCount(weekAgo(), now())));
    placeholders.registerStatic("network_players_unique_month", parameters -> database.query(PlayerCountQueries.uniquePlayerCount(monthAgo(), now())));
    placeholders.registerStatic("server_tps_day", parameters -> decimals.apply(database.query(TPSQueries.averageTPS(dayAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("server_tps_week", parameters -> decimals.apply(database.query(TPSQueries.averageTPS(weekAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("server_tps_month", parameters -> decimals.apply(database.query(TPSQueries.averageTPS(monthAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("server_cpu_day", parameters -> percentage.apply(database.query(TPSQueries.averageCPU(dayAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("server_cpu_week", parameters -> percentage.apply(database.query(TPSQueries.averageCPU(weekAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("server_cpu_month", parameters -> percentage.apply(database.query(TPSQueries.averageCPU(monthAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("server_ram_day", parameters -> formatters.byteSizeLong().apply(database.query(TPSQueries.averageRAM(dayAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("server_ram_week", parameters -> formatters.byteSizeLong().apply(database.query(TPSQueries.averageRAM(weekAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("server_ram_month", parameters -> formatters.byteSizeLong().apply(database.query(TPSQueries.averageRAM(monthAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("server_chunks_day", parameters -> database.query(TPSQueries.averageChunks(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_chunks_week", parameters -> database.query(TPSQueries.averageChunks(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_chunks_month", parameters -> database.query(TPSQueries.averageChunks(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_entities_day", parameters -> database.query(TPSQueries.averageEntities(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_entities_week", parameters -> database.query(TPSQueries.averageEntities(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_entities_month", parameters -> database.query(TPSQueries.averageEntities(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_max_free_disk_day", parameters -> database.query(TPSQueries.maxFreeDisk(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_max_free_disk_week", parameters -> database.query(TPSQueries.maxFreeDisk(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_max_free_disk_month", parameters -> database.query(TPSQueries.maxFreeDisk(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_min_free_disk_day", parameters -> database.query(TPSQueries.minFreeDisk(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_min_free_disk_week", parameters -> database.query(TPSQueries.minFreeDisk(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_min_free_disk_month", parameters -> database.query(TPSQueries.minFreeDisk(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_average_free_disk_day", parameters -> database.query(TPSQueries.averageFreeDisk(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_average_free_disk_week", parameters -> database.query(TPSQueries.averageFreeDisk(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_average_free_disk_month", parameters -> database.query(TPSQueries.averageFreeDisk(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("server_name", () -> serverInfo.getServer().getName());
    placeholders.registerStatic("server_uuid", serverInfo::getServerUUID);
    registerDynamicCategoryPlaceholders(placeholders, database);
}
Also used : Database(com.djrapitops.plan.storage.database.Database)

Example 82 with Database

use of com.djrapitops.plan.storage.database.Database in project Plan by plan-player-analytics.

the class SessionPlaceHolders method register.

@Override
public void register(PlanPlaceholders placeholders) {
    int tzOffsetMs = config.getTimeZone().getOffset(System.currentTimeMillis());
    Formatter<Long> timeAmount = formatters.timeAmount();
    Formatter<DateHolder> year = formatters.year();
    Formatter<Double> decimals = formatters.decimals();
    Database database = dbSystem.getDatabase();
    placeholders.registerStatic("sessions_play_time_total", parameters -> timeAmount.apply(database.query(SessionQueries.playtime(0L, now(), getServerUUID(parameters)))));
    placeholders.registerStatic("sessions_play_time_total_raw", parameters -> database.query(SessionQueries.playtime(0L, now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_play_time_day", parameters -> timeAmount.apply(database.query(SessionQueries.playtime(dayAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("sessions_play_time_day_raw", parameters -> database.query(SessionQueries.playtime(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_play_time_week", parameters -> timeAmount.apply(database.query(SessionQueries.playtime(weekAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("sessions_play_time_week_raw", parameters -> database.query(SessionQueries.playtime(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_play_time_month", parameters -> timeAmount.apply(database.query(SessionQueries.playtime(monthAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("sessions_play_time_month_raw", parameters -> database.query(SessionQueries.playtime(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_active_time_total", parameters -> timeAmount.apply(database.query(SessionQueries.activePlaytime(0L, now(), getServerUUID(parameters)))));
    placeholders.registerStatic("sessions_active_time_total_raw", parameters -> database.query(SessionQueries.activePlaytime(0L, now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_active_time_day", parameters -> timeAmount.apply(database.query(SessionQueries.activePlaytime(dayAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("sessions_active_time_day_raw", parameters -> database.query(SessionQueries.activePlaytime(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_active_time_week", parameters -> timeAmount.apply(database.query(SessionQueries.activePlaytime(weekAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("sessions_active_time_week_raw", parameters -> database.query(SessionQueries.activePlaytime(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_active_time_month", parameters -> timeAmount.apply(database.query(SessionQueries.activePlaytime(monthAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("sessions_active_time_month_raw", parameters -> database.query(SessionQueries.activePlaytime(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_afk_time_total", parameters -> timeAmount.apply(database.query(SessionQueries.afkTime(0L, now(), getServerUUID(parameters)))));
    placeholders.registerStatic("sessions_afk_time_total_raw", parameters -> database.query(SessionQueries.afkTime(0L, now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_afk_time_day", parameters -> timeAmount.apply(database.query(SessionQueries.afkTime(dayAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("sessions_afk_time_day_raw", parameters -> database.query(SessionQueries.afkTime(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_afk_time_week", parameters -> timeAmount.apply(database.query(SessionQueries.afkTime(weekAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("sessions_afk_time_week_raw", parameters -> database.query(SessionQueries.afkTime(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_afk_time_month", parameters -> timeAmount.apply(database.query(SessionQueries.afkTime(monthAgo(), now(), getServerUUID(parameters)))));
    placeholders.registerStatic("sessions_afk_time_month_raw", parameters -> database.query(SessionQueries.afkTime(monthAgo(), now(), getServerUUID(parameters))));
    PlanPlaceholders.StaticPlaceholderLoader uniquePlayers = parameters -> database.query(PlayerCountQueries.newPlayerCount(0L, now(), getServerUUID(parameters)));
    placeholders.registerStatic("sessions_unique_players_total", uniquePlayers);
    placeholders.registerStatic("sessions_new_players_total", uniquePlayers);
    placeholders.registerStatic("sessions_unique_players_day", parameters -> database.query(PlayerCountQueries.uniquePlayerCount(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_unique_players_today", parameters -> {
        NavigableMap<Long, Integer> playerCounts = database.query(PlayerCountQueries.uniquePlayerCounts(dayAgo(), now(), config.getTimeZone().getOffset(now()), getServerUUID(parameters)));
        return playerCounts.isEmpty() ? 0 : playerCounts.lastEntry().getValue();
    });
    placeholders.registerStatic("sessions_unique_players_week", parameters -> database.query(PlayerCountQueries.uniquePlayerCount(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_unique_players_month", parameters -> database.query(PlayerCountQueries.uniquePlayerCount(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_players_death_total", parameters -> database.query(KillQueries.deathCount(0L, now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_players_death_day", parameters -> database.query(KillQueries.deathCount(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_players_death_week", parameters -> database.query(KillQueries.deathCount(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_players_death_month", parameters -> database.query(KillQueries.deathCount(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_players_kill_total", parameters -> database.query(KillQueries.playerKillCount(0L, now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_players_kill_day", parameters -> database.query(KillQueries.playerKillCount(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_players_kill_week", parameters -> database.query(KillQueries.playerKillCount(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_players_kill_month", parameters -> database.query(KillQueries.playerKillCount(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_mob_kill_total", parameters -> database.query(KillQueries.mobKillCount(0L, now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_mob_kill_day", parameters -> database.query(KillQueries.mobKillCount(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_mob_kill_week", parameters -> database.query(KillQueries.mobKillCount(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_mob_kill_month", parameters -> database.query(KillQueries.mobKillCount(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_average_session_length_total", parameters -> getPlaytime(database, 0L, now(), getServerUUID(parameters), timeAmount));
    placeholders.registerStatic("sessions_average_session_length_day", parameters -> getPlaytime(database, dayAgo(), now(), getServerUUID(parameters), timeAmount));
    placeholders.registerStatic("sessions_average_session_length_week", parameters -> getPlaytime(database, weekAgo(), now(), getServerUUID(parameters), timeAmount));
    placeholders.registerStatic("sessions_average_session_length_month", parameters -> getPlaytime(database, monthAgo(), now(), getServerUUID(parameters), timeAmount));
    placeholders.registerStatic("sessions_average_unique_players_total", parameters -> database.query(PlayerCountQueries.averageUniquePlayerCount(0L, now(), tzOffsetMs, getServerUUID(parameters))));
    placeholders.registerStatic("sessions_average_unique_players_day", parameters -> database.query(PlayerCountQueries.averageUniquePlayerCount(dayAgo(), now(), tzOffsetMs, getServerUUID(parameters))));
    placeholders.registerStatic("sessions_average_unique_players_week", parameters -> database.query(PlayerCountQueries.averageUniquePlayerCount(weekAgo(), now(), tzOffsetMs, getServerUUID(parameters))));
    placeholders.registerStatic("sessions_average_unique_players_month", parameters -> database.query(PlayerCountQueries.averageUniquePlayerCount(monthAgo(), now(), tzOffsetMs, getServerUUID(parameters))));
    placeholders.registerStatic("sessions_new_players_day", parameters -> database.query(PlayerCountQueries.newPlayerCount(dayAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_new_players_week", parameters -> database.query(PlayerCountQueries.newPlayerCount(weekAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("sessions_new_players_month", parameters -> database.query(PlayerCountQueries.newPlayerCount(monthAgo(), now(), getServerUUID(parameters))));
    placeholders.registerStatic("ping_total", parameters -> decimals.apply(database.query(PingQueries.averagePing(0L, now(), getServerUUID(parameters)))) + " ms");
    placeholders.registerStatic("ping_day", parameters -> decimals.apply(database.query(PingQueries.averagePing(dayAgo(), now(), getServerUUID(parameters)))) + " ms");
    placeholders.registerStatic("ping_week", parameters -> decimals.apply(database.query(PingQueries.averagePing(weekAgo(), now(), getServerUUID(parameters)))) + " ms");
    placeholders.registerStatic("ping_month", parameters -> decimals.apply(database.query(PingQueries.averagePing(monthAgo(), now(), getServerUUID(parameters)))) + " ms");
    placeholders.registerStatic("sessions_peak_count", parameters -> database.query(TPSQueries.fetchAllTimePeakPlayerCount(getServerUUID(parameters))).map(DateObj::getValue).orElse(0));
    placeholders.registerStatic("sessions_peak_date", parameters -> database.query(TPSQueries.fetchAllTimePeakPlayerCount(getServerUUID(parameters))).map(year).orElse("-"));
    placeholders.registerStatic("sessions_recent_peak_count", parameters -> database.query(TPSQueries.fetchPeakPlayerCount(getServerUUID(parameters), now() - TimeUnit.DAYS.toMillis(2L))).map(DateObj::getValue).orElse(0));
    placeholders.registerStatic("sessions_recent_peak_date", parameters -> database.query(TPSQueries.fetchPeakPlayerCount(getServerUUID(parameters), now() - TimeUnit.DAYS.toMillis(2L))).map(year).orElse("-"));
}
Also used : PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) ServerInfo(com.djrapitops.plan.identification.ServerInfo) ServerUUID(com.djrapitops.plan.identification.ServerUUID) Formatters(com.djrapitops.plan.delivery.formatting.Formatters) Singleton(javax.inject.Singleton) NavigableMap(java.util.NavigableMap) Database(com.djrapitops.plan.storage.database.Database) DBSystem(com.djrapitops.plan.storage.database.DBSystem) Inject(javax.inject.Inject) TimeUnit(java.util.concurrent.TimeUnit) DateHolder(com.djrapitops.plan.delivery.domain.DateHolder) DateObj(com.djrapitops.plan.delivery.domain.DateObj) Server(com.djrapitops.plan.identification.Server) MiscUtils(com.djrapitops.plan.utilities.MiscUtils) Optional(java.util.Optional) Arguments(com.djrapitops.plan.commands.use.Arguments) com.djrapitops.plan.storage.database.queries.objects(com.djrapitops.plan.storage.database.queries.objects) Formatter(com.djrapitops.plan.delivery.formatting.Formatter) PlayerCountQueries(com.djrapitops.plan.storage.database.queries.analysis.PlayerCountQueries) DateHolder(com.djrapitops.plan.delivery.domain.DateHolder) DateObj(com.djrapitops.plan.delivery.domain.DateObj) Database(com.djrapitops.plan.storage.database.Database)

Example 83 with Database

use of com.djrapitops.plan.storage.database.Database in project Plan by plan-player-analytics.

the class GeolocationQueriesTest method pingIsGroupedByGeolocationAppropriately.

@Test
default void pingIsGroupedByGeolocationAppropriately() {
    UUID[] uuids = storeSpecificGeolocations();
    Database db = db();
    long time = System.currentTimeMillis();
    List<DateObj<Integer>> ping = Collections.singletonList(new DateObj<>(time, 5));
    for (UUID uuid : uuids) {
        db.executeTransaction(new PingStoreTransaction(uuid, serverUUID(), ping));
    }
    Map<String, Ping> got = db.query(PingQueries.fetchPingDataOfServerByGeolocation(serverUUID()));
    Map<String, Ping> expected = new HashMap<>();
    // first user has a more recent connection from Finland so their country should be counted as Finland.
    Ping expectedPing = new Ping(time, serverUUID(), 5, 5, 5);
    expected.put("Finland", expectedPing);
    expected.put("Sweden", expectedPing);
    expected.put("Not Known", expectedPing);
    expected.put("Local Machine", expectedPing);
    expected.put("Denmark", expectedPing);
    assertEquals(expected, got);
}
Also used : DateObj(com.djrapitops.plan.delivery.domain.DateObj) Ping(com.djrapitops.plan.gathering.domain.Ping) Database(com.djrapitops.plan.storage.database.Database) PingStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.PingStoreTransaction) Test(org.junit.jupiter.api.Test)

Example 84 with Database

use of com.djrapitops.plan.storage.database.Database in project Plan by plan-player-analytics.

the class GeolocationQueriesTest method storeSpecificGeolocations.

default UUID[] storeSpecificGeolocations() {
    UUID firstUuid = UUID.randomUUID();
    UUID secondUuid = UUID.randomUUID();
    UUID thirdUuid = UUID.randomUUID();
    UUID fourthUuid = UUID.randomUUID();
    UUID fifthUuid = UUID.randomUUID();
    UUID sixthUuid = UUID.randomUUID();
    UUID[] uuids = { firstUuid, secondUuid, thirdUuid, fourthUuid, fifthUuid, sixthUuid };
    Database db = db();
    for (UUID uuid : uuids) {
        db.executeTransaction(new PlayerServerRegisterTransaction(uuid, () -> 0L, "", serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
    }
    save(firstUuid, new GeoInfo("Norway", 0));
    save(firstUuid, new GeoInfo("Finland", 5));
    save(secondUuid, new GeoInfo("Sweden", 0));
    save(thirdUuid, new GeoInfo("Denmark", 0));
    save(fourthUuid, new GeoInfo("Denmark", 0));
    save(fifthUuid, new GeoInfo("Not Known", 0));
    save(sixthUuid, new GeoInfo("Local Machine", 0));
    return uuids;
}
Also used : Database(com.djrapitops.plan.storage.database.Database) PlayerServerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction) GeoInfo(com.djrapitops.plan.gathering.domain.GeoInfo)

Example 85 with Database

use of com.djrapitops.plan.storage.database.Database in project Plan by plan-player-analytics.

the class ServerOverviewJSONCreator method createNumbersMap.

private Map<String, Object> createNumbersMap(ServerUUID serverUUID) {
    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(ServerAggregateQueries.serverUserCount(serverUUID));
    numbers.put("total_players", userCount);
    numbers.put("regular_players", db.query(ActivityIndexQueries.fetchRegularPlayerCount(now, serverUUID, playtimeThreshold)));
    numbers.put("online_players", getOnlinePlayers(serverUUID, db));
    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, serverUUID));
    numbers.put("playtime", timeAmount.apply(totalPlaytime));
    numbers.put("player_playtime", userCount != 0 ? timeAmount.apply(totalPlaytime / userCount) : "-");
    numbers.put("sessions", db.query(SessionQueries.sessionCount(0L, now, serverUUID)));
    numbers.put("player_kills", db.query(KillQueries.playerKillCount(0L, now, serverUUID)));
    numbers.put("mob_kills", db.query(KillQueries.mobKillCount(0L, now, serverUUID)));
    numbers.put("deaths", db.query(KillQueries.deathCount(0L, now, serverUUID)));
    numbers.put("current_uptime", serverUptimeCalculator.getServerUptimeMillis(serverUUID).map(timeAmount).orElse(locale.getString(GenericLang.UNAVAILABLE)));
    return numbers;
}
Also used : HashMap(java.util.HashMap) DateObj(com.djrapitops.plan.delivery.domain.DateObj) Database(com.djrapitops.plan.storage.database.Database)

Aggregations

Database (com.djrapitops.plan.storage.database.Database)95 ServerUUID (com.djrapitops.plan.identification.ServerUUID)20 HashMap (java.util.HashMap)18 StoreIconTransaction (com.djrapitops.plan.extension.implementation.storage.transactions.StoreIconTransaction)12 ProviderInformation (com.djrapitops.plan.extension.implementation.ProviderInformation)11 StoreProviderTransaction (com.djrapitops.plan.extension.implementation.storage.transactions.providers.StoreProviderTransaction)9 DBSystem (com.djrapitops.plan.storage.database.DBSystem)9 UUID (java.util.UUID)9 TPSMutator (com.djrapitops.plan.delivery.domain.mutators.TPSMutator)7 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)7 DateMap (com.djrapitops.plan.delivery.domain.DateMap)6 PlayerName (com.djrapitops.plan.delivery.domain.PlayerName)6 ServerName (com.djrapitops.plan.delivery.domain.ServerName)6 Point (com.djrapitops.plan.delivery.rendering.json.graphs.line.Point)6 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)6 ServerInfo (com.djrapitops.plan.identification.ServerInfo)6 InetAddress (java.net.InetAddress)6 DateObj (com.djrapitops.plan.delivery.domain.DateObj)5 LineGraphFactory (com.djrapitops.plan.delivery.rendering.json.graphs.line.LineGraphFactory)5 DBOpException (com.djrapitops.plan.exceptions.database.DBOpException)5