aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-07-25 23:53:44 +1200
committerGitHub <noreply@github.com>2016-07-25 23:53:44 +1200
commit7e20896334f4f6927cf14c5272cf7d893efc3a05 (patch)
tree4ce04313dde4989a4c5b16816ddfeab1a6381876 /src/org/traccar/database
parent8c4eb2eff9da9bf0538e413444c1e6dae981b99e (diff)
parent80847cc39a0570a91618c2d9da283767a99fd975 (diff)
downloadtrackermap-server-7e20896334f4f6927cf14c5272cf7d893efc3a05.tar.gz
trackermap-server-7e20896334f4f6927cf14c5272cf7d893efc3a05.tar.bz2
trackermap-server-7e20896334f4f6927cf14c5272cf7d893efc3a05.zip
Merge pull request #2149 from Abyss777/lastposition_reorganization
Move lastPosition update to the end of pipeline
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r--src/org/traccar/database/DeviceManager.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/org/traccar/database/DeviceManager.java b/src/org/traccar/database/DeviceManager.java
index 4dd7b41cb..5a0c87985 100644
--- a/src/org/traccar/database/DeviceManager.java
+++ b/src/org/traccar/database/DeviceManager.java
@@ -105,7 +105,6 @@ public class DeviceManager implements IdentityManager {
}
}
device.setStatus(Device.STATUS_OFFLINE);
- device.setMotion(Device.STATUS_STOPPED);
}
}
for (Long cachedDeviceId : devicesById.keySet()) {
@@ -176,7 +175,6 @@ public class DeviceManager implements IdentityManager {
if (devicesById.containsKey(device.getId())) {
Device cachedDevice = devicesById.get(device.getId());
cachedDevice.setStatus(device.getStatus());
- cachedDevice.setMotion(device.getMotion());
}
}
@@ -191,10 +189,14 @@ public class DeviceManager implements IdentityManager {
positions.remove(deviceId);
}
+ public boolean isLatestPosition(Position position) {
+ Position lastPosition = getLastPosition(position.getDeviceId());
+ return lastPosition == null || position.getFixTime().compareTo(lastPosition.getFixTime()) > 0;
+ }
+
public void updateLatestPosition(Position position) throws SQLException {
- Position lastPosition = getLastPosition(position.getDeviceId());
- if (lastPosition == null || position.getFixTime().compareTo(lastPosition.getFixTime()) > 0) {
+ if (isLatestPosition(position)) {
dataManager.updateLatestPosition(position);