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);
}
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);
}
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();
}
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);
}
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);
}
Aggregations