use of com.djrapitops.plan.storage.database.Database 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);
}
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 GraphJSONCreator method geolocationGraphsJSONAsMap.
public Map<String, Object> geolocationGraphsJSONAsMap() {
Database db = dbSystem.getDatabase();
Map<String, Integer> geolocationCounts = db.query(GeoInfoQueries.networkGeolocationCounts());
return createGeolocationJSON(geolocationCounts);
}
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 playersOnlineGraph.
public String playersOnlineGraph(ServerUUID serverUUID) {
Database db = dbSystem.getDatabase();
long now = System.currentTimeMillis();
long halfYearAgo = now - TimeUnit.DAYS.toMillis(180L);
List<Point> points = Lists.map(db.query(TPSQueries.fetchPlayersOnlineOfServer(halfYearAgo, now, serverUUID)), Point::fromDateObj);
return "{\"playersOnline\":" + graphs.line().lineGraph(points).toHighChartsSeries() + ",\"color\":\"" + theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE) + "\"}";
}
Aggregations