use of com.djrapitops.plan.gathering.domain.GMTimes in project Plan by plan-player-analytics.
the class WorldAliasSettings method getGMTimesPerAlias.
public Map<String, GMTimes> getGMTimesPerAlias(WorldTimes worldTimes) {
Map<String, GMTimes> gmTimesPerAlias = new HashMap<>();
String[] gms = GMTimes.getGMKeyArray();
for (Map.Entry<String, GMTimes> entry : worldTimes.getWorldTimes().entrySet()) {
String worldName = entry.getKey();
GMTimes gmTimes = entry.getValue();
Optional<String> foundAlias = getAlias(worldName);
if (!foundAlias.isPresent()) {
addWorld(worldName);
}
String alias = foundAlias.orElse(worldName);
GMTimes aliasGMTimes = gmTimesPerAlias.getOrDefault(alias, new GMTimes());
for (String gm : gms) {
aliasGMTimes.addTime(gm, gmTimes.getTime(gm));
}
gmTimesPerAlias.put(alias, aliasGMTimes);
}
return gmTimesPerAlias;
}
use of com.djrapitops.plan.gathering.domain.GMTimes in project Plan by plan-player-analytics.
the class PieGraphFactory method worldPie.
public WorldPie worldPie(WorldTimes worldTimes) {
WorldAliasSettings worldAliasSettings = config.getWorldAliasSettings();
Map<String, Long> playtimePerAlias = worldAliasSettings.getPlaytimePerAlias(worldTimes);
Map<String, GMTimes> gmTimesPerAlias = worldAliasSettings.getGMTimesPerAlias(worldTimes);
String[] colors = theme.getPieColors(ThemeVal.GRAPH_WORLD_PIE);
boolean orderByPercentage = config.isTrue(DisplaySettings.ORDER_WORLD_PIE_BY_PERCENTAGE);
return new WorldPie(playtimePerAlias, gmTimesPerAlias, colors, orderByPercentage);
}
use of com.djrapitops.plan.gathering.domain.GMTimes in project Plan by plan-player-analytics.
the class WorldTimesQueries method fetchServerTotalWorldTimes.
/**
* Sum total playtime per world on a server.
*
* @param serverUUID Server UUID of the Plan server.
* @return WorldTimes with world name - playtime ms information.
*/
public static Query<WorldTimes> fetchServerTotalWorldTimes(ServerUUID serverUUID) {
String sql = SELECT_WORLD_TIMES_STATEMENT_START + SELECT_WORLD_TIMES_JOIN_WORLD_NAME + WHERE + WorldTimesTable.TABLE_NAME + '.' + WorldTimesTable.SERVER_UUID + "=?" + GROUP_BY + WORLD_COLUMN;
return new QueryStatement<WorldTimes>(sql, 1000) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, serverUUID.toString());
}
@Override
public WorldTimes processResults(ResultSet set) throws SQLException {
String[] gms = GMTimes.getGMKeyArray();
WorldTimes worldTimes = new WorldTimes();
while (set.next()) {
String worldName = set.getString(WORLD_COLUMN);
GMTimes gmTimes = extractGMTimes(set, gms);
worldTimes.setGMTimesForWorld(worldName, gmTimes);
}
return worldTimes;
}
};
}
use of com.djrapitops.plan.gathering.domain.GMTimes in project Plan by plan-player-analytics.
the class WorldTimesQueries method fetchGMTimes.
public static Query<GMTimes> fetchGMTimes(long after, long before, ServerUUID serverUUID) {
String sql = SELECT + "SUM(" + WorldTimesTable.SURVIVAL + ") as SURVIVAL," + "SUM(" + WorldTimesTable.CREATIVE + ") as CREATIVE," + "SUM(" + WorldTimesTable.ADVENTURE + ") as ADVENTURE," + "SUM(" + WorldTimesTable.SPECTATOR + ") as SPECTATOR" + FROM + WorldTimesTable.TABLE_NAME + " w1" + INNER_JOIN + SessionsTable.TABLE_NAME + " s1 on s1." + SessionsTable.ID + '=' + WorldTimesTable.SESSION_ID + WHERE + "w1." + WorldTimesTable.SERVER_UUID + "=?" + AND + SessionsTable.SESSION_START + ">=?" + AND + SessionsTable.SESSION_END + "<=?";
return new QueryStatement<GMTimes>(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, serverUUID.toString());
statement.setLong(2, after);
statement.setLong(3, before);
}
@Override
public GMTimes processResults(ResultSet set) throws SQLException {
return set.next() ? extractGMTimes(set, GMTimes.getGMKeyArray()) : new GMTimes();
}
};
}
use of com.djrapitops.plan.gathering.domain.GMTimes in project Plan by plan-player-analytics.
the class WorldTimesTable method addSessionWorldTimesToBatch.
public static void addSessionWorldTimesToBatch(PreparedStatement statement, FinishedSession session, String[] gms) throws SQLException {
UUID uuid = session.getPlayerUUID();
ServerUUID serverUUID = session.getServerUUID();
Optional<WorldTimes> worldTimes = session.getExtraData().get(WorldTimes.class);
if (!worldTimes.isPresent())
return;
for (Map.Entry<String, GMTimes> worldTimesEntry : worldTimes.get().getWorldTimes().entrySet()) {
String worldName = worldTimesEntry.getKey();
GMTimes gmTimes = worldTimesEntry.getValue();
// Session ID select statement
statement.setString(1, uuid.toString());
statement.setString(2, serverUUID.toString());
statement.setLong(3, session.getStart());
statement.setLong(4, session.getEnd());
// World ID select statement
statement.setString(5, worldName);
statement.setString(6, serverUUID.toString());
statement.setString(7, uuid.toString());
statement.setString(8, serverUUID.toString());
statement.setLong(9, gmTimes.getTime(gms[0]));
statement.setLong(10, gmTimes.getTime(gms[1]));
statement.setLong(11, gmTimes.getTime(gms[2]));
statement.setLong(12, gmTimes.getTime(gms[3]));
statement.addBatch();
}
}
Aggregations