Search in sources :

Example 1 with DateMap

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

the class QueryJSONResolver method getActivityGraphData.

private Map<String, Object> getActivityGraphData(Set<UUID> playerUUIDs, List<ServerUUID> serverUUIDs, long after, long before) {
    Database database = dbSystem.getDatabase();
    Long threshold = config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD);
    long twoMonthsBeforeLastDate = before - TimeAmount.MONTH.toMillis(2L);
    long stopDate = Math.max(twoMonthsBeforeLastDate, after);
    DateMap<Map<String, Integer>> activityData = new DateMap<>();
    for (long time = before; time >= stopDate; time -= TimeAmount.WEEK.toMillis(1L)) {
        activityData.put(time, database.query(NetworkActivityIndexQueries.fetchActivityIndexGroupingsOn(time, threshold, playerUUIDs, serverUUIDs)));
    }
    return graphJSONCreator.createActivityGraphJSON(activityData);
}
Also used : DateMap(com.djrapitops.plan.delivery.domain.DateMap) Database(com.djrapitops.plan.storage.database.Database) DateMap(com.djrapitops.plan.delivery.domain.DateMap)

Example 2 with DateMap

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

the class GraphJSONCreator method activityGraphsJSONAsMap.

public Map<String, Object> activityGraphsJSONAsMap(ServerUUID serverUUID) {
    Database db = dbSystem.getDatabase();
    long date = System.currentTimeMillis();
    Long threshold = config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD);
    DateMap<Map<String, Integer>> activityData = new DateMap<>();
    for (long time = date; time >= date - TimeAmount.MONTH.toMillis(2L); time -= TimeAmount.WEEK.toMillis(1L)) {
        activityData.put(time, db.query(ActivityIndexQueries.fetchActivityIndexGroupingsOn(time, serverUUID, threshold)));
    }
    return createActivityGraphJSON(activityData);
}
Also used : DateMap(com.djrapitops.plan.delivery.domain.DateMap) Database(com.djrapitops.plan.storage.database.Database) Map(java.util.Map) NavigableMap(java.util.NavigableMap) WorldMap(com.djrapitops.plan.delivery.rendering.json.graphs.special.WorldMap) DateMap(com.djrapitops.plan.delivery.domain.DateMap)

Example 3 with DateMap

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

the class GraphJSONCreator method createActivityGraphJSON.

public Map<String, Object> createActivityGraphJSON(DateMap<Map<String, Integer>> activityData) {
    Map.Entry<Long, Map<String, Integer>> lastActivityEntry = activityData.lastEntry();
    Pie activityPie = graphs.pie().activityPie(lastActivityEntry != null ? lastActivityEntry.getValue() : Collections.emptyMap());
    StackGraph activityStackGraph = graphs.stack().activityStackGraph(activityData);
    return Maps.builder(String.class, Object.class).put("activity_series", activityStackGraph.getDataSets()).put("activity_labels", activityStackGraph.getLabels()).put("activity_pie_series", activityPie.getSlices()).build();
}
Also used : StackGraph(com.djrapitops.plan.delivery.rendering.json.graphs.stack.StackGraph) Map(java.util.Map) NavigableMap(java.util.NavigableMap) WorldMap(com.djrapitops.plan.delivery.rendering.json.graphs.special.WorldMap) DateMap(com.djrapitops.plan.delivery.domain.DateMap) Pie(com.djrapitops.plan.delivery.rendering.json.graphs.pie.Pie) WorldPie(com.djrapitops.plan.delivery.rendering.json.graphs.pie.WorldPie)

Example 4 with DateMap

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

the class QueryJSONResolver method getActivityGraphData.

private Map<String, Object> getActivityGraphData(Set<Integer> userIds, List<ServerUUID> serverUUIDs, long after, long before) {
    Database database = dbSystem.getDatabase();
    Long threshold = config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD);
    long twoMonthsBeforeLastDate = before - TimeAmount.MONTH.toMillis(2L);
    long stopDate = Math.max(twoMonthsBeforeLastDate, after);
    DateMap<Map<String, Integer>> activityData = new DateMap<>();
    for (long time = before; time >= stopDate; time -= TimeAmount.WEEK.toMillis(1L)) {
        activityData.put(time, database.query(NetworkActivityIndexQueries.fetchActivityIndexGroupingsOn(time, threshold, userIds, serverUUIDs)));
    }
    return graphJSONCreator.createActivityGraphJSON(activityData);
}
Also used : DateMap(com.djrapitops.plan.delivery.domain.DateMap) Database(com.djrapitops.plan.storage.database.Database) DateMap(com.djrapitops.plan.delivery.domain.DateMap)

Example 5 with DateMap

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

the class GraphJSONCreator method activityGraphsJSONAsMap.

public Map<String, Object> activityGraphsJSONAsMap() {
    Database db = dbSystem.getDatabase();
    long date = System.currentTimeMillis();
    Long threshold = config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD);
    DateMap<Map<String, Integer>> activityData = new DateMap<>();
    for (long time = date; time >= date - TimeAmount.MONTH.toMillis(2L); time -= TimeAmount.WEEK.toMillis(1L)) {
        activityData.put(time, db.query(NetworkActivityIndexQueries.fetchActivityIndexGroupingsOn(time, threshold)));
    }
    return createActivityGraphJSON(activityData);
}
Also used : DateMap(com.djrapitops.plan.delivery.domain.DateMap) Database(com.djrapitops.plan.storage.database.Database) Map(java.util.Map) NavigableMap(java.util.NavigableMap) WorldMap(com.djrapitops.plan.delivery.rendering.json.graphs.special.WorldMap) DateMap(com.djrapitops.plan.delivery.domain.DateMap)

Aggregations

DateMap (com.djrapitops.plan.delivery.domain.DateMap)5 Database (com.djrapitops.plan.storage.database.Database)4 WorldMap (com.djrapitops.plan.delivery.rendering.json.graphs.special.WorldMap)3 Map (java.util.Map)3 NavigableMap (java.util.NavigableMap)3 Pie (com.djrapitops.plan.delivery.rendering.json.graphs.pie.Pie)1 WorldPie (com.djrapitops.plan.delivery.rendering.json.graphs.pie.WorldPie)1 StackGraph (com.djrapitops.plan.delivery.rendering.json.graphs.stack.StackGraph)1