use of com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalServerResultsTransaction 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();
}
}
use of com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalServerResultsTransaction in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method unsatisfiedServerConditionalResultsAreCleaned.
@Test
default void unsatisfiedServerConditionalResultsAreCleaned() {
ExtensionSvc extensionService = extensionService();
ConditionalExtension.condition = true;
extensionService.register(new ConditionalExtension());
extensionService.updateServerValues(CallEvents.MANUAL);
// Check that the wanted data exists
checkThatServerDataExists(ConditionalExtension.condition);
// Reverse condition
ConditionalExtension.condition = false;
extensionService.updateServerValues(CallEvents.MANUAL);
db().executeTransaction(new RemoveUnsatisfiedConditionalServerResultsTransaction());
// Check that the wanted data exists
checkThatServerDataExists(ConditionalExtension.condition);
// Reverse condition
ConditionalExtension.condition = false;
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
db().executeTransaction(new RemoveUnsatisfiedConditionalServerResultsTransaction());
// Check that the wanted data exists
checkThatServerDataExists(ConditionalExtension.condition);
}
Aggregations