use of com.djrapitops.plan.storage.database.transactions.commands.RemovePlayerTransaction in project Plan by plan-player-analytics.
the class DatabaseTest method testRemovalSingleUser.
@Test
default void testRemovalSingleUser() {
saveUserTwo();
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
saveTwoWorlds();
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
execute(DataStoreQueries.storeSession(session));
db().executeTransaction(new NicknameStoreTransaction(playerUUID, new Nickname("TestNick", RandomData.randomTime(), serverUUID()), (uuid, name) -> false));
db().executeTransaction(new GeoInfoStoreTransaction(playerUUID, new GeoInfo("TestLoc", RandomData.randomTime())));
assertTrue(db().query(PlayerFetchQueries.isPlayerRegistered(playerUUID)));
db().executeTransaction(new RemovePlayerTransaction(playerUUID));
assertFalse(db().query(PlayerFetchQueries.isPlayerRegistered(playerUUID)));
assertFalse(db().query(PlayerFetchQueries.isPlayerRegisteredOnServer(playerUUID, serverUUID())));
assertTrue(db().query(NicknameQueries.fetchNicknameDataOfPlayer(playerUUID)).isEmpty());
assertTrue(db().query(GeoInfoQueries.fetchPlayerGeoInformation(playerUUID)).isEmpty());
assertQueryIsEmpty(db(), SessionQueries.fetchSessionsOfPlayer(playerUUID));
}
use of com.djrapitops.plan.storage.database.transactions.commands.RemovePlayerTransaction in project Plan by plan-player-analytics.
the class DBCleanTask method cleanOldPlayers.
// VisibleForTesting
public int cleanOldPlayers(Database database) {
long now = System.currentTimeMillis();
long keepActiveAfter = now - config.get(TimeSettings.DELETE_INACTIVE_PLAYERS_AFTER);
List<UUID> inactivePlayers = database.query(fetchInactivePlayerUUIDs(keepActiveAfter));
for (UUID playerUUID : inactivePlayers) {
queryService.playerRemoved(playerUUID);
database.executeTransaction(new RemovePlayerTransaction(playerUUID));
}
return inactivePlayers.size();
}
Aggregations