Search in sources :

Example 56 with Database

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);
}
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 57 with Database

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));
}
Also used : Database(com.djrapitops.plan.storage.database.Database) LineGraphFactory(com.djrapitops.plan.delivery.rendering.json.graphs.line.LineGraphFactory) Point(com.djrapitops.plan.delivery.rendering.json.graphs.line.Point)

Example 58 with Database

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);
}
Also used : Database(com.djrapitops.plan.storage.database.Database)

Example 59 with Database

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));
}
Also used : Database(com.djrapitops.plan.storage.database.Database) LineGraphFactory(com.djrapitops.plan.delivery.rendering.json.graphs.line.LineGraphFactory) Point(com.djrapitops.plan.delivery.rendering.json.graphs.line.Point)

Example 60 with Database

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) + "\"}";
}
Also used : Database(com.djrapitops.plan.storage.database.Database) Point(com.djrapitops.plan.delivery.rendering.json.graphs.line.Point)

Aggregations

Database (com.djrapitops.plan.storage.database.Database)90 ServerUUID (com.djrapitops.plan.identification.ServerUUID)18 HashMap (java.util.HashMap)18 StoreIconTransaction (com.djrapitops.plan.extension.implementation.storage.transactions.StoreIconTransaction)12 ProviderInformation (com.djrapitops.plan.extension.implementation.ProviderInformation)11 UUID (java.util.UUID)10 StoreProviderTransaction (com.djrapitops.plan.extension.implementation.storage.transactions.providers.StoreProviderTransaction)9 DBSystem (com.djrapitops.plan.storage.database.DBSystem)9 TPSMutator (com.djrapitops.plan.delivery.domain.mutators.TPSMutator)7 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)7 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 Inject (javax.inject.Inject)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