use of com.djrapitops.plan.gathering.domain.WorldTimes in project Plan by plan-player-analytics.
the class WorldAliasSettings method getLongestWorldPlayed.
public String getLongestWorldPlayed(ActiveSession session) {
Optional<WorldTimes> foundWorldTimes = session.getExtraData(WorldTimes.class);
if (!foundWorldTimes.isPresent()) {
return locale.get().getString(HtmlLang.UNIT_NO_DATA);
}
WorldTimes worldTimes = foundWorldTimes.orElseGet(WorldTimes::new);
return worldTimes.getCurrentWorld().map(currentWorld -> "Current: " + getAlias(currentWorld).orElse(currentWorld)).orElse("Current: " + locale.get().getString(GenericLang.UNAVAILABLE));
}
use of com.djrapitops.plan.gathering.domain.WorldTimes in project Plan by plan-player-analytics.
the class SessionQueriesTest method worldTimesAreSavedWithSessionWithoutWorlds.
@Test
default void worldTimesAreSavedWithSessionWithoutWorlds() {
prepareForSessionSave();
// Remove the worlds from the database so that they need to also be saved.
execute(new ExecStatement("DELETE FROM " + WorldTable.TABLE_NAME) {
@Override
public void prepare(PreparedStatement statement) {
// Nothing needed
}
});
WorldTimes worldTimes = RandomData.randomWorldTimes(worlds);
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID);
session.getExtraData().put(WorldTimes.class, worldTimes);
List<FinishedSession> sessions = new ArrayList<>();
sessions.add(session);
db().executeTransaction(new Transaction() {
@Override
protected void performOperations() {
execute(LargeStoreQueries.storeAllSessionsWithKillAndWorldData(sessions));
}
});
List<FinishedSession> allSessions = db().query(SessionQueries.fetchAllSessions());
assertEquals(worldTimes, allSessions.get(0).getExtraData(WorldTimes.class).get());
}
use of com.djrapitops.plan.gathering.domain.WorldTimes in project Plan by plan-player-analytics.
the class SessionQueriesTest method serverWorldTimesMatchTotal.
@Test
default void serverWorldTimesMatchTotal() {
worldTimesAreSavedWithSession();
FinishedSession session = db().query(SessionQueries.fetchSessionsOfPlayer(playerUUID)).get(serverUUID()).get(0);
WorldTimes expected = session.getExtraData(WorldTimes.class).orElseThrow(AssertionError::new);
WorldTimes worldTimesOfServer = db().query(WorldTimesQueries.fetchServerTotalWorldTimes(serverUUID()));
assertEquals(expected, worldTimesOfServer);
}
use of com.djrapitops.plan.gathering.domain.WorldTimes in project Plan by plan-player-analytics.
the class SessionQueriesTest method worldTimesAreSavedWithSession.
@Test
default void worldTimesAreSavedWithSession() {
prepareForSessionSave();
WorldTimes worldTimes = RandomData.randomWorldTimes(worlds);
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID);
session.getExtraData().put(WorldTimes.class, worldTimes);
List<FinishedSession> sessions = new ArrayList<>();
sessions.add(session);
db().executeTransaction(new Transaction() {
@Override
protected void performOperations() {
execute(LargeStoreQueries.storeAllSessionsWithKillAndWorldData(sessions));
}
});
List<FinishedSession> allSessions = db().query(SessionQueries.fetchAllSessions());
assertEquals(worldTimes, allSessions.get(0).getExtraData(WorldTimes.class).get());
}
use of com.djrapitops.plan.gathering.domain.WorldTimes in project Plan by plan-player-analytics.
the class PerServerMutator method flatMapWorldTimes.
public WorldTimes flatMapWorldTimes() {
WorldTimes total = new WorldTimes();
for (DataContainer container : data.values()) {
if (container.supports(PerServerKeys.WORLD_TIMES)) {
WorldTimes worldTimes = container.getUnsafe(PerServerKeys.WORLD_TIMES);
total.add(worldTimes);
}
}
return total;
}
Aggregations