use of com.djrapitops.plan.storage.database.transactions.init.RemoveDuplicateUserInfoTransaction in project Plan by plan-player-analytics.
the class UserInfoQueriesTest method cleanRemovesOnlyDuplicatedUserInfo.
@Test
default void cleanRemovesOnlyDuplicatedUserInfo() throws ExecutionException, InterruptedException {
// Store one duplicate
db().executeTransaction(new Transaction() {
@Override
protected void performOperations() {
execute(DataStoreQueries.registerUserInfo(playerUUID, 0L, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME.get()));
execute(DataStoreQueries.registerUserInfo(playerUUID, 0L, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME.get()));
execute(DataStoreQueries.registerUserInfo(player2UUID, 0L, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME.get()));
}
}).get();
db().executeTransaction(new RemoveDuplicateUserInfoTransaction());
Set<UserInfo> found = db().query(UserInfoQueries.fetchUserInformationOfUser(playerUUID));
assertEquals(Collections.singleton(new UserInfo(playerUUID, serverUUID(), 0, false, TestConstants.GET_PLAYER_HOSTNAME.get(), false)), found);
Set<UserInfo> found2 = db().query(UserInfoQueries.fetchUserInformationOfUser(player2UUID));
assertEquals(Collections.singleton(new UserInfo(player2UUID, serverUUID(), 0, false, TestConstants.GET_PLAYER_HOSTNAME.get(), false)), found2);
}
use of com.djrapitops.plan.storage.database.transactions.init.RemoveDuplicateUserInfoTransaction in project Plan by plan-player-analytics.
the class DBCleanTask method run.
@Override
public void run() {
Database database = dbSystem.getDatabase();
try {
if (database.getState() != Database.State.CLOSED) {
database.executeTransaction(new RemoveOldSampledDataTransaction(serverInfo.getServerUUID(), config.get(TimeSettings.DELETE_TPS_DATA_AFTER), config.get(TimeSettings.DELETE_PING_DATA_AFTER)));
database.executeTransaction(new RemoveDuplicateUserInfoTransaction());
database.executeTransaction(new RemoveUnsatisfiedConditionalPlayerResultsTransaction());
database.executeTransaction(new RemoveUnsatisfiedConditionalServerResultsTransaction());
int removed = cleanOldPlayers(database);
if (removed > 0) {
logger.info(locale.getString(PluginLang.DB_NOTIFY_CLEAN, removed));
}
Long deleteExtensionDataAfter = config.get(TimeSettings.DELETE_EXTENSION_DATA_AFTER);
Long databaseCleanPeriod = config.get(TimeSettings.CLEAN_DATABASE_PERIOD);
if (databaseCleanPeriod > deleteExtensionDataAfter) {
logger.warn("Data of Disabled Extensions can not be cleaned due to " + TimeSettings.CLEAN_DATABASE_PERIOD.getPath() + " being larger than " + TimeSettings.DELETE_EXTENSION_DATA_AFTER.getPath());
}
// for plugins being deleted all the time.
if (System.currentTimeMillis() - lastReload <= deleteExtensionDataAfter) {
database.executeTransaction(new RemoveOldExtensionsTransaction(config.getExtensionSettings(), deleteExtensionDataAfter, serverInfo.getServerUUID()));
}
}
} catch (DBOpException e) {
errorLogger.error(e);
cancel();
}
}
Aggregations