Search in sources :

Example 1 with RemoveUnsatisfiedConditionalPlayerResultsTransaction

use of com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalPlayerResultsTransaction 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();
    }
}
Also used : DBOpException(com.djrapitops.plan.exceptions.database.DBOpException) RemoveUnsatisfiedConditionalPlayerResultsTransaction(com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalPlayerResultsTransaction) RemoveOldExtensionsTransaction(com.djrapitops.plan.storage.database.transactions.init.RemoveOldExtensionsTransaction) RemoveOldSampledDataTransaction(com.djrapitops.plan.storage.database.transactions.init.RemoveOldSampledDataTransaction) RemoveUnsatisfiedConditionalServerResultsTransaction(com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalServerResultsTransaction) Database(com.djrapitops.plan.storage.database.Database) RemoveDuplicateUserInfoTransaction(com.djrapitops.plan.storage.database.transactions.init.RemoveDuplicateUserInfoTransaction)

Example 2 with RemoveUnsatisfiedConditionalPlayerResultsTransaction

use of com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalPlayerResultsTransaction in project Plan by plan-player-analytics.

the class ExtensionsDatabaseTest method unsatisfiedPlayerConditionalResultsAreCleaned.

@Test
default void unsatisfiedPlayerConditionalResultsAreCleaned() {
    ExtensionSvc extensionService = extensionService();
    extensionService.register(new ConditionalExtension());
    ConditionalExtension.condition = true;
    extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
    // Check that the wanted data exists
    checkThatPlayerDataExists(ConditionalExtension.condition);
    // Reverse condition
    ConditionalExtension.condition = false;
    extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
    db().executeTransaction(new RemoveUnsatisfiedConditionalPlayerResultsTransaction());
    // Check that the wanted data exists
    checkThatPlayerDataExists(ConditionalExtension.condition);
    // Reverse condition
    ConditionalExtension.condition = false;
    extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
    db().executeTransaction(new RemoveUnsatisfiedConditionalPlayerResultsTransaction());
    // Check that the wanted data exists
    checkThatPlayerDataExists(ConditionalExtension.condition);
}
Also used : RemoveUnsatisfiedConditionalPlayerResultsTransaction(com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalPlayerResultsTransaction) ExtensionSvc(com.djrapitops.plan.extension.ExtensionSvc) Test(org.junit.jupiter.api.Test)

Aggregations

RemoveUnsatisfiedConditionalPlayerResultsTransaction (com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalPlayerResultsTransaction)2 DBOpException (com.djrapitops.plan.exceptions.database.DBOpException)1 ExtensionSvc (com.djrapitops.plan.extension.ExtensionSvc)1 RemoveUnsatisfiedConditionalServerResultsTransaction (com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalServerResultsTransaction)1 Database (com.djrapitops.plan.storage.database.Database)1 RemoveDuplicateUserInfoTransaction (com.djrapitops.plan.storage.database.transactions.init.RemoveDuplicateUserInfoTransaction)1 RemoveOldExtensionsTransaction (com.djrapitops.plan.storage.database.transactions.init.RemoveOldExtensionsTransaction)1 RemoveOldSampledDataTransaction (com.djrapitops.plan.storage.database.transactions.init.RemoveOldSampledDataTransaction)1 Test (org.junit.jupiter.api.Test)1