mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-02 14:37:45 +01:00
Tests against Activity index calculation mismatch
This commit is contained in:
parent
d17a962505
commit
194bbe9850
@ -48,6 +48,14 @@ public class ServerTablePlayersQuery implements Query<List<TablePlayer>> {
|
||||
private final long activeMsThreshold;
|
||||
private final int xMostRecentPlayers;
|
||||
|
||||
/**
|
||||
* Create a new query.
|
||||
*
|
||||
* @param serverUUID UUID of the Plan server.
|
||||
* @param date Date used for Activity Index calculation
|
||||
* @param activeMsThreshold Playtime threshold for Activity Index calculation
|
||||
* @param xMostRecentPlayers Limit query size
|
||||
*/
|
||||
public ServerTablePlayersQuery(UUID serverUUID, long date, long activeMsThreshold, int xMostRecentPlayers) {
|
||||
this.serverUUID = serverUUID;
|
||||
this.date = date;
|
||||
|
@ -1153,6 +1153,46 @@ public interface DatabaseTest {
|
||||
assertEquals(expected, got);
|
||||
}
|
||||
|
||||
@Test
|
||||
default void activityIndexCalculationsMatch() {
|
||||
sessionsAreStoredWithAllData();
|
||||
|
||||
long date = System.currentTimeMillis();
|
||||
long playtimeThreshold = TimeUnit.HOURS.toMillis(5L);
|
||||
List<Session> sessions = db().query(SessionQueries.fetchSessionsOfPlayer(playerUUID))
|
||||
.values().stream().flatMap(Collection::stream).collect(Collectors.toList());
|
||||
|
||||
ActivityIndex javaCalculation = new ActivityIndex(sessions, date, playtimeThreshold);
|
||||
|
||||
List<TablePlayer> players = db().query(new ServerTablePlayersQuery(serverUUID(), date, playtimeThreshold, 5));
|
||||
Optional<TablePlayer> found = players.stream().filter(tp -> playerUUID.equals(tp.getPlayerUUID())).findFirst();
|
||||
assertTrue(found.isPresent());
|
||||
Optional<ActivityIndex> currentActivityIndex = found.get().getCurrentActivityIndex();
|
||||
assertTrue(currentActivityIndex.isPresent());
|
||||
|
||||
assertEquals(javaCalculation.getValue(), currentActivityIndex.get().getValue(), 0.001);
|
||||
}
|
||||
|
||||
@Test
|
||||
default void networkActivityIndexCalculationsMatch() {
|
||||
sessionsAreStoredWithAllData();
|
||||
|
||||
long date = System.currentTimeMillis();
|
||||
long playtimeThreshold = TimeUnit.HOURS.toMillis(5L);
|
||||
List<Session> sessions = db().query(SessionQueries.fetchSessionsOfPlayer(playerUUID))
|
||||
.values().stream().flatMap(Collection::stream).collect(Collectors.toList());
|
||||
|
||||
ActivityIndex javaCalculation = new ActivityIndex(sessions, date, playtimeThreshold);
|
||||
|
||||
List<TablePlayer> players = db().query(new NetworkTablePlayersQuery(date, playtimeThreshold, 5));
|
||||
Optional<TablePlayer> found = players.stream().filter(tp -> playerUUID.equals(tp.getPlayerUUID())).findFirst();
|
||||
assertTrue(found.isPresent());
|
||||
Optional<ActivityIndex> currentActivityIndex = found.get().getCurrentActivityIndex();
|
||||
assertTrue(currentActivityIndex.isPresent());
|
||||
|
||||
assertEquals(javaCalculation.getValue(), currentActivityIndex.get().getValue(), 0.001);
|
||||
}
|
||||
|
||||
@Test
|
||||
default void extensionPlayerValuesAreStored() {
|
||||
ExtensionServiceImplementation extensionService = (ExtensionServiceImplementation) system().getExtensionService();
|
||||
|
Loading…
Reference in New Issue
Block a user