Search in sources :

Example 1 with TPSComparator

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;
}
Also used : TPS(com.djrapitops.plan.gathering.domain.TPS) TPSComparator(com.djrapitops.plan.utilities.comparators.TPSComparator)

Example 2 with TPSComparator

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;
}
Also used : TPS(com.djrapitops.plan.gathering.domain.TPS) TPSComparator(com.djrapitops.plan.utilities.comparators.TPSComparator) Point(com.djrapitops.plan.delivery.rendering.json.graphs.line.Point)

Example 3 with TPSComparator

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())));
}
Also used : TPS(com.djrapitops.plan.gathering.domain.TPS) TPSComparator(com.djrapitops.plan.utilities.comparators.TPSComparator) Test(org.junit.jupiter.api.Test)

Aggregations

TPS (com.djrapitops.plan.gathering.domain.TPS)3 TPSComparator (com.djrapitops.plan.utilities.comparators.TPSComparator)3 Point (com.djrapitops.plan.delivery.rendering.json.graphs.line.Point)1 Test (org.junit.jupiter.api.Test)1