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.java10
-rw-r--r--src/org/traccar/protocol/MiniFinderProtocolDecoder.java5
-rw-r--r--test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java3
5 files changed, 19 insertions, 5 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..2f2cf1275 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -308,11 +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) {
+ 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", timeLimit)
.executeUpdate();
}
}
diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
index c3279da43..8bfb4fb36 100644
--- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
+++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
@@ -79,7 +79,10 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
private void decodeFlags(Position position, int flags) {
- position.setValid(BitUtil.check(flags, 0));
+ position.setValid(BitUtil.to(flags, 2) > 0);
+ if (BitUtil.check(flags, 1)) {
+ position.set(Position.KEY_APPROXIMATE, true);
+ }
if (BitUtil.check(flags, 2)) {
position.set(Position.KEY_ALARM, Position.ALARM_FAULT);
diff --git a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java
index 124dcd852..e5bd127ac 100644
--- a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java
@@ -10,6 +10,9 @@ public class MeiligaoProtocolDecoderTest extends ProtocolTest {
MeiligaoProtocolDecoder decoder = new MeiligaoProtocolDecoder(new MeiligaoProtocol());
+ verifyAttributes(decoder, binary(
+ "242400561001ffffffffff99553030303030302e3030302c562c303030302e303030302c532c30303030302e303030302c572c302e30302c302e30302c3232303839392c2c2c412a37457c7c307c3030303059ae0d0a0000"));
+
verifyPosition(decoder, binary(
"242400706573402852404799553130313932372e3030302c412c313732362e38323739332c4e2c30373832382e31393637312c452c312e382c362e342c3137313131362c2c2a32427c312e36387c3534342e327c313030307c303030302c303030307c3030303032383638373a1a0d0a"));