aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--setup/default.xml4
-rw-r--r--src/org/traccar/Main.java2
-rw-r--r--src/org/traccar/database/DataManager.java7
3 files changed, 10 insertions, 3 deletions
diff --git a/setup/default.xml b/setup/default.xml
index 82f2798dd..e80c516dd 100644
--- a/setup/default.xml
+++ b/setup/default.xml
@@ -289,6 +289,10 @@
DELETE FROM positions WHERE serverTime < :serverTime AND id NOT IN (SELECT positionId FROM devices)
</entry>
+ <entry key='database.deleteEvents'>
+ DELETE FROM events WHERE serverTime &lt; :serverTime
+ </entry>
+
<entry key='database.selectAttributeAliases'>
SELECT * FROM attribute_aliases
</entry>
diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java
index 21625d3c1..1e2db2693 100644
--- a/src/org/traccar/Main.java
+++ b/src/org/traccar/Main.java
@@ -44,7 +44,7 @@ public final class Main {
@Override
public void run() {
try {
- Context.getDataManager().clearPositionsHistory();
+ Context.getDataManager().clearHistory();
} catch (SQLException error) {
Log.warning(error);
}
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 0c5f458a2..2aeb759f6 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -308,12 +308,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) {
QueryBuilder.create(dataSource, getQuery("database.deletePositions"))
.setDate("serverTime", new Date(System.currentTimeMillis() - historyDays * 24 * 3600 * 1000))
.executeUpdate();
+ QueryBuilder.create(dataSource, getQuery("database.deleteEvents"))
+ .setDate("serverTime", new Date(System.currentTimeMillis() - historyDays * 24 * 3600 * 1000))
+ .executeUpdate();
}
}