use of com.djrapitops.plan.utilities.comparators.TPSComparator in project Plan by plan-player-analytics.
the class TPSMutator method serverDownTime.
public long serverDownTime() {
long lastDate = -1;
long downTime = 0;
tpsData.sort(new TPSComparator());
for (TPS tps : tpsData) {
long date = tps.getDate();
if (lastDate == -1) {
lastDate = date;
continue;
}
long diff = date - lastDate;
if (diff > TimeUnit.MINUTES.toMillis(3L)) {
downTime += diff;
}
lastDate = date;
}
return downTime;
}
use of com.djrapitops.plan.utilities.comparators.TPSComparator in project Plan by plan-player-analytics.
the class TPSMutator method serverOccupiedTime.
public long serverOccupiedTime() {
long lastDate = -1;
long activeTime = 0;
tpsData.sort(new TPSComparator());
for (TPS tps : tpsData) {
long date = tps.getDate();
if (lastDate == -1) {
lastDate = date;
continue;
}
int players = tps.getPlayers();
long diff = date - lastDate;
if (players > 0 && diff <= TimeUnit.MINUTES.toMillis(3L)) {
activeTime += diff;
}
lastDate = date;
}
return activeTime;
}
use of com.djrapitops.plan.utilities.comparators.TPSComparator in project Plan by plan-player-analytics.
the class TPSQueriesTest method tpsIsStored.
@Test
default void tpsIsStored() {
List<TPS> expected = RandomData.randomTPS();
for (TPS tps : expected) {
execute(DataStoreQueries.storeTPS(serverUUID(), tps));
}
forcePersistenceCheck();
expected.sort(new TPSComparator());
assertEquals(expected, db().query(TPSQueries.fetchTPSDataOfServer(Long.MIN_VALUE, Long.MAX_VALUE, serverUUID())));
}
Aggregations