From 832d448a68eaed31e8a86c7b0d4fce169b51bc4d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 12 May 2017 04:42:31 +1200 Subject: Small clear history refactoring --- src/org/traccar/database/DataManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 2aeb759f6..2f2cf1275 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -311,11 +311,12 @@ public class DataManager { 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", new Date(System.currentTimeMillis() - historyDays * 24 * 3600 * 1000)) + .setDate("serverTime", timeLimit) .executeUpdate(); } } -- cgit v1.2.3