aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r--src/org/traccar/database/DataManager.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index acbaac17b..840a8931c 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -312,11 +312,15 @@ public class DataManager {
.executeQuery(Position.class);
}
- public void clearPositionsHistory() throws SQLException {
- long historyDays = config.getInteger("database.positionsHistoryDays");
+ public void clearHistory() throws SQLException {
+ long historyDays = config.getInteger("database.historyDays");
if (historyDays != 0) {
+ Date timeLimit = new Date(System.currentTimeMillis() - historyDays * 24 * 3600 * 1000);
QueryBuilder.create(dataSource, getQuery("database.deletePositions"))
- .setDate("serverTime", new Date(System.currentTimeMillis() - historyDays * 24 * 3600 * 1000))
+ .setDate("serverTime", timeLimit)
+ .executeUpdate();
+ QueryBuilder.create(dataSource, getQuery("database.deleteEvents"))
+ .setDate("serverTime", timeLimit)
.executeUpdate();
}
}