diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/access/transactions/init/RemoveOldSampledDataTransaction.java b/Plan/common/src/main/java/com/djrapitops/plan/db/access/transactions/init/RemoveOldSampledDataTransaction.java index 46b99d5c4..c86739439 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/db/access/transactions/init/RemoveOldSampledDataTransaction.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/db/access/transactions/init/RemoveOldSampledDataTransaction.java @@ -23,7 +23,6 @@ import com.djrapitops.plan.db.access.queries.objects.TPSQueries; import com.djrapitops.plan.db.access.transactions.Transaction; import com.djrapitops.plan.db.sql.tables.PingTable; import com.djrapitops.plan.db.sql.tables.TPSTable; -import com.djrapitops.plugin.api.TimeAmount; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -38,11 +37,17 @@ import java.util.UUID; public class RemoveOldSampledDataTransaction extends Transaction { private final UUID serverUUID; + private final long deleteTPSOlderThanMs; + private final long deletePingOlderThanMs; public RemoveOldSampledDataTransaction( - UUID serverUUID + UUID serverUUID, + long deleteTPSOlderThanMs, + long deletePingOlderThanMs ) { this.serverUUID = serverUUID; + this.deleteTPSOlderThanMs = deleteTPSOlderThanMs; + this.deletePingOlderThanMs = deletePingOlderThanMs; } @Override @@ -61,9 +66,7 @@ public class RemoveOldSampledDataTransaction extends Transaction { return new ExecStatement(sql) { @Override public void prepare(PreparedStatement statement) throws SQLException { - // More than 3 Months ago. - long threeMonths = TimeAmount.MONTH.toMillis(3L); - statement.setLong(1, System.currentTimeMillis() - threeMonths); + statement.setLong(1, System.currentTimeMillis() - deleteTPSOlderThanMs); statement.setInt(2, allTimePlayerPeak); } }; @@ -77,8 +80,7 @@ public class RemoveOldSampledDataTransaction extends Transaction { return new ExecStatement(sql) { @Override public void prepare(PreparedStatement statement) throws SQLException { - long twoWeeks = TimeAmount.WEEK.toMillis(2L); - statement.setLong(1, System.currentTimeMillis() - twoWeeks); + statement.setLong(1, System.currentTimeMillis() - deletePingOlderThanMs); } }; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/tasks/DBCleanTask.java b/Plan/common/src/main/java/com/djrapitops/plan/db/tasks/DBCleanTask.java index 596a3c49c..f2c5fa681 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/db/tasks/DBCleanTask.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/db/tasks/DBCleanTask.java @@ -85,7 +85,11 @@ public class DBCleanTask extends AbsRunnable { Database database = dbSystem.getDatabase(); try { if (database.getState() != Database.State.CLOSED) { - database.executeTransaction(new RemoveOldSampledDataTransaction(serverInfo.getServerUUID())); + 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()); @@ -103,7 +107,7 @@ public class DBCleanTask extends AbsRunnable { @VisibleForTesting public int cleanOldPlayers(Database database) { long now = System.currentTimeMillis(); - long keepActiveAfter = now - config.get(TimeSettings.KEEP_INACTIVE_PLAYERS); + long keepActiveAfter = now - config.get(TimeSettings.DELETE_INACTIVE_PLAYERS_AFTER); List inactivePlayers = database.query(fetchInactivePlayerUUIDs(keepActiveAfter)); for (UUID uuid : inactivePlayers) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/paths/TimeSettings.java b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/paths/TimeSettings.java index 316600799..0eb48a5fc 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/paths/TimeSettings.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/paths/TimeSettings.java @@ -35,7 +35,9 @@ public class TimeSettings { public static final Setting AFK_THRESHOLD = new TimeSetting("Time.Thresholds.AFK_threshold"); public static final Setting ACTIVE_LOGIN_THRESHOLD = new IntegerSetting("Time.Thresholds.Activity_index.Login_threshold", Setting::timeValidator); public static final Setting ACTIVE_PLAY_THRESHOLD = new TimeSetting("Time.Thresholds.Activity_index.Playtime_threshold"); - public static final Setting KEEP_INACTIVE_PLAYERS = new TimeSetting("Time.Thresholds.Remove_inactive_player_data_after"); + public static final Setting DELETE_INACTIVE_PLAYERS_AFTER = new TimeSetting("Time.Thresholds.Remove_inactive_player_data_after"); + public static final Setting DELETE_TPS_DATA_AFTER = new TimeSetting("Time.Thresholds.Remove_time_series_data_after"); + public static final Setting DELETE_PING_DATA_AFTER = new TimeSetting("Time.Thresholds.Remove_ping_data_after"); public static final Setting ANALYSIS_REFRESH_PERIOD = new TimeSetting("Time.Periodic_tasks.Analysis_refresh_every"); public static final Setting EXTENSION_DATA_REFRESH_PERIOD = new TimeSetting("Time.Periodic_tasks.Extension_data_refresh_every"); public static final Setting CLEAN_CACHE_PERIOD = new TimeSetting("Time.Periodic_tasks.Clean_caches_every"); diff --git a/Plan/common/src/main/resources/assets/plan/bungeeconfig.yml b/Plan/common/src/main/resources/assets/plan/bungeeconfig.yml index 7567f6e8e..643555de4 100644 --- a/Plan/common/src/main/resources/assets/plan/bungeeconfig.yml +++ b/Plan/common/src/main/resources/assets/plan/bungeeconfig.yml @@ -85,6 +85,11 @@ Time: Unit: MINUTES Remove_inactive_player_data_after: 180 Unit: DAYS + # Includes players online, tps and performance time series + Remove_time_series_data_after: 90 + Unit: DAYS + Remove_ping_data_after: 14 + Unit: DAYS Periodic_tasks: Extension_data_refresh_every: 1 Unit: HOURS diff --git a/Plan/common/src/main/resources/assets/plan/config.yml b/Plan/common/src/main/resources/assets/plan/config.yml index 0fbd95ab5..766ede2b8 100644 --- a/Plan/common/src/main/resources/assets/plan/config.yml +++ b/Plan/common/src/main/resources/assets/plan/config.yml @@ -90,6 +90,11 @@ Time: Unit: MINUTES Remove_inactive_player_data_after: 180 Unit: DAYS + # Includes players online, tps and performance time series + Remove_time_series_data_after: 90 + Unit: DAYS + Remove_ping_data_after: 14 + Unit: DAYS Periodic_tasks: Analysis_refresh_every: 60 Unit: MINUTES