diff options
author | ninioe <ninioe@gmail.com> | 2016-07-13 15:29:39 +0300 |
---|---|---|
committer | ninioe <ninioe@gmail.com> | 2016-07-13 15:29:39 +0300 |
commit | 0e7cb81693a1067af81b6d74544f16d01fce8b6e (patch) | |
tree | 2c7069e1d124406d86a7abfa02e3cb7bae4fdf37 /src/org/traccar/database/DataManager.java | |
parent | d045c1e2174146ddc8ad8b2ef4442863f3d84a11 (diff) | |
download | trackermap-server-0e7cb81693a1067af81b6d74544f16d01fce8b6e.tar.gz trackermap-server-0e7cb81693a1067af81b6d74544f16d01fce8b6e.tar.bz2 trackermap-server-0e7cb81693a1067af81b6d74544f16d01fce8b6e.zip |
changes Anton asked me
Diffstat (limited to 'src/org/traccar/database/DataManager.java')
-rw-r--r-- | src/org/traccar/database/DataManager.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 7fd672849..a9fc09448 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -521,22 +521,24 @@ public class DataManager implements IdentityManager { .executeQuery(Position.class); } - //added by Erez public void clearPositionsHistory() throws SQLException { //SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd"); - String histDays = config.getString("database.positionsHistoryDays"); - if (histDays == null) { - histDays = "7"; + int histDays = config.getInteger("database.positionsHistoryDays"); + if (histDays == 0) { + return; + } + + String sql = getQuery("database.clearPositionsHistory"); + if (sql == null) { + return; } - int n = Integer.parseInt(histDays); for (Device device : getAllDevices()) { Date lastUpdate = device.getLastUpdate(); if(lastUpdate != null){ - Date dateBefore = new Date(lastUpdate.getTime() - n * 24 * 3600 * 1000 ); //Subtract n days + Date dateBefore = new Date(lastUpdate.getTime() - histDays * 24 * 3600 * 1000 ); //Subtract histDays days //String dt = s.format(dateBefore); - String sql = "DELETE FROM positions WHERE deviceid=:deviceId and servertime<:serverTime"; QueryBuilder.create(dataSource, sql) .setLong("deviceId", device.getId()) |