Search in sources :

Example 6 with DataContainer

use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.

the class SupplierDataContainerTest method safeUnsafeKeyRawNull.

@Test
void safeUnsafeKeyRawNull() {
    DataContainer container = new SupplierDataContainer();
    container.putRawData(TEST_KEY, null);
    assertTrue(container.supports(TEST_KEY));
    assertNull(container.getUnsafe(TEST_KEY));
}
Also used : SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer) SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) Test(org.junit.jupiter.api.Test)

Example 7 with DataContainer

use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.

the class PerServerMutator method flatMapWorldTimes.

public WorldTimes flatMapWorldTimes() {
    WorldTimes total = new WorldTimes();
    for (DataContainer container : data.values()) {
        if (container.supports(PerServerKeys.WORLD_TIMES)) {
            WorldTimes worldTimes = container.getUnsafe(PerServerKeys.WORLD_TIMES);
            total.add(worldTimes);
        }
    }
    return total;
}
Also used : DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer) WorldTimes(com.djrapitops.plan.gathering.domain.WorldTimes)

Example 8 with DataContainer

use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.

the class PerServerMutator method worldTimesPerServer.

public Map<ServerUUID, WorldTimes> worldTimesPerServer() {
    Map<ServerUUID, WorldTimes> timesMap = new HashMap<>();
    for (Map.Entry<ServerUUID, DataContainer> entry : data.entrySet()) {
        DataContainer container = entry.getValue();
        timesMap.put(entry.getKey(), container.getValue(PerServerKeys.WORLD_TIMES).orElse(new WorldTimes()));
    }
    return timesMap;
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer) WorldTimes(com.djrapitops.plan.gathering.domain.WorldTimes)

Example 9 with DataContainer

use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.

the class ServerAccordion method asMaps.

public List<Map<String, Object>> asMaps() {
    List<Map<String, Object>> servers = new ArrayList<>();
    for (Map.Entry<ServerUUID, DataContainer> entry : perServer.entrySet()) {
        ServerUUID serverUUID = entry.getKey();
        DataContainer ofServer = entry.getValue();
        Map<String, Object> server = new HashMap<>();
        String serverName = serverNames.getOrDefault(serverUUID, unknown);
        WorldTimes worldTimes = ofServer.getValue(PerServerKeys.WORLD_TIMES).orElse(new WorldTimes());
        SessionsMutator sessionsMutator = SessionsMutator.forContainer(ofServer);
        server.put("server_name", serverName);
        server.put("banned", ofServer.getValue(PerServerKeys.BANNED).orElse(false));
        server.put("operator", ofServer.getValue(PerServerKeys.OPERATOR).orElse(false));
        server.put("registered", year.apply(ofServer.getValue(PerServerKeys.REGISTERED).orElse(0L)));
        server.put("last_seen", year.apply(sessionsMutator.toLastSeen()));
        server.put("join_address", ofServer.getValue(PerServerKeys.JOIN_ADDRESS).orElse("-"));
        server.put("session_count", sessionsMutator.count());
        server.put("playtime", timeAmount.apply(sessionsMutator.toPlaytime()));
        server.put("afk_time", timeAmount.apply(sessionsMutator.toAfkTime()));
        server.put("session_median", timeAmount.apply(sessionsMutator.toMedianSessionLength()));
        server.put("longest_session_length", timeAmount.apply(sessionsMutator.toLongestSessionLength()));
        server.put("mob_kills", sessionsMutator.toMobKillCount());
        server.put("player_kills", sessionsMutator.toPlayerKillCount());
        server.put("deaths", sessionsMutator.toDeathCount());
        WorldPie worldPie = graphs.pie().worldPie(worldTimes);
        server.put("world_pie_series", worldPie.getSlices());
        server.put("gm_series", worldPie.toHighChartsDrillDownMaps());
        servers.add(server);
    }
    return servers;
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WorldTimes(com.djrapitops.plan.gathering.domain.WorldTimes) DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer) WorldPie(com.djrapitops.plan.delivery.rendering.json.graphs.pie.WorldPie) HashMap(java.util.HashMap) Map(java.util.Map) SessionsMutator(com.djrapitops.plan.delivery.domain.mutators.SessionsMutator)

Example 10 with DataContainer

use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.

the class SupplierDataContainerTest method safeUnsafeKeyNullSupplier.

@Test
void safeUnsafeKeyNullSupplier() {
    DataContainer container = new SupplierDataContainer();
    container.putSupplier(TEST_KEY, null);
    assertFalse(container.supports(TEST_KEY));
}
Also used : SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer) SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) Test(org.junit.jupiter.api.Test)

Aggregations

DataContainer (com.djrapitops.plan.delivery.domain.container.DataContainer)14 SupplierDataContainer (com.djrapitops.plan.delivery.domain.container.SupplierDataContainer)9 Test (org.junit.jupiter.api.Test)8 ServerUUID (com.djrapitops.plan.identification.ServerUUID)4 WorldTimes (com.djrapitops.plan.gathering.domain.WorldTimes)3 Map (java.util.Map)2 PerServerContainer (com.djrapitops.plan.delivery.domain.container.PerServerContainer)1 SessionsMutator (com.djrapitops.plan.delivery.domain.mutators.SessionsMutator)1 WorldPie (com.djrapitops.plan.delivery.rendering.json.graphs.pie.WorldPie)1 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1