diff options
author | ninioe <ninioe@gmail.com> | 2016-08-01 16:12:47 +0300 |
---|---|---|
committer | ninioe <ninioe@gmail.com> | 2016-08-01 16:12:47 +0300 |
commit | 94781fa3ba35e494e309aee19a5e15c14d3193c1 (patch) | |
tree | a1e4a90e9a2fce3db8bc51981aeb8a23cced5e6d /src/org/traccar/database/DataManager.java | |
parent | b4841fa0a6293c0b895cf6bb65c6c2d871c78397 (diff) | |
parent | e177e7d083a4dd3f64172802661bf658d26d1163 (diff) | |
download | trackermap-server-94781fa3ba35e494e309aee19a5e15c14d3193c1.tar.gz trackermap-server-94781fa3ba35e494e309aee19a5e15c14d3193c1.tar.bz2 trackermap-server-94781fa3ba35e494e309aee19a5e15c14d3193c1.zip |
Merge remote-tracking branch 'refs/remotes/tananaev/master'
Diffstat (limited to 'src/org/traccar/database/DataManager.java')
-rw-r--r-- | src/org/traccar/database/DataManager.java | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 04d0d44ea..78f1b4109 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -305,28 +305,11 @@ public class DataManager { } public void clearPositionsHistory() throws SQLException { - int histDays = config.getInteger("database.positionsHistoryDays"); - if (histDays == 0) { - return; - } - - String sql = getQuery("database.clearPositionsHistory"); - if (sql == null) { - return; - } - - for (Device device : getAllDevices()) { - Date lastUpdate = device.getLastUpdate(); - if (lastUpdate != null) { - - Date dateBefore = new Date(lastUpdate.getTime() - histDays * 24 * 3600 * 1000); - - QueryBuilder.create(dataSource, sql) - .setLong("positionId", device.getPositionId()) - .setLong("deviceId", device.getId()) - .setDate("serverTime", dateBefore) - .executeUpdate(); - } + int historyDays = config.getInteger("database.positionsHistoryDays"); + if (historyDays != 0) { + QueryBuilder.create(dataSource, getQuery("database.deletePositions")) + .setDate("serverTime", new Date(System.currentTimeMillis() - historyDays * 24 * 3600 * 1000)) + .executeUpdate(); } } |