How to delete future positions sent by the tracker

jcorreajr7 years ago

Some trackers that use, sometimes send positions to the year 2022.
I checked that there is the option:
Filter.future


<entry key='filter.enable'>true</entry>
<entry key='filter.future'>86400</entry>

I'm setting the Traccar to use it.

But the old data that was sent with this future year is causing problems.

Even the tracker sending correct positions, the real-time map displays only the year position of 2022. Clicking the device and looking at "State > Time" 2022 is displayed.

For testing, I changed the "valid" field in the database to "0" but it still displays the last position, which was sent with the wrong date. (Year of 2022)


UPDATE positions SET valid = 0 WHERE fixtime > '2018-01-01 10:27:00' AND deviceid=89;

What is the most effective way to disable data with the wrong year, which is already stored in the database?

Traccar Version: 3.11

Anton Tananaev7 years ago

You need to update or clear "positionid" filed in the devices table. Then restart service.

jcorreajr7 years ago

Ok, it worked perfectly.

1 - I checked which devices were associated with the wrong future dates


select id,deviceid,valid,servertime,devicetime,fixtime,latitude,longitude from positions where id in (select positionid from devices) and fixtime > '2018-01-01 07:10:00';

2 - I checked the last valid position for each device


select id,deviceid,valid,servertime,devicetime,fixtime,latitude,longitude from positions where deviceid=????? order by servertime DESC LIMIT 1;

3 - I made the update and pointed the device to the last valid position.


UPDATE devices SET positionid = ????? WHERE id=??

After this change, I restarted the traction and it was OK

Note:
Before doing the update I already included in the configuration file the options below:


<entry key='filter.enable'>true</entry>
<entry key='filter.future'>86400</entry>
Superego6 years ago

Hi, all.
I put filter future key

<entry key='filter.enable'>true</entry>
<entry key='filter.future'>86400</entry>

but anyway got problem with future date.
Is there a comment why it' s so?

Best regards,
Egons

Anton Tananaev6 years ago

Filtering only affects new data. It doesn't affect what you already have in the database. You have to manually clean that up.

Superego6 years ago

Oh, thank's for quick response.
Yes. I put that filter because some months ago got that problem with future data and then add config to get rid of that problem and filter future data. But anyway got that problem. Is syntax ok?

jcorreajr6 years ago

Did you restart the service?

Superego6 years ago

I think yes, but will try again.

jcorreajr6 years ago

I may be wrong, but I believe that the version you use must be equal to or greater than 3.11

Superego6 years ago

yea, it's 3.15

Superego6 years ago

I think it's relevant to this topic also - is there a method how to delete wrong data database H2 input? I run Traccar on Ubuntu.

Anton Tananaev6 years ago

Connect to the database and remove it.

Javier Gonzalez5 years ago

New database query should be as follow:

select id,deviceid,valid,servertime,devicetime,fixtime,latitude,longitude from tc_positions where id in (select positionid from tc_devices) and fixtime > '2019-12-31 07:10:00';
Javier Gonzalez5 years ago

May be an improved version of this sql

select id,deviceid,valid,servertime,devicetime,fixtime,latitude,longitude from tc_positions where id in (select positionid from tc_devices) and fixtime > (CURDATE() + 1);
Javier Gonzalez5 years ago

I´ve tried to make it work with mongodb but no success so far. I am not 100% sure with the syntax in traccar.xml

<entry key='database.driver'>com.mongodb.jdbc.Driver</entry>
<entry key='database.url'>jdbc:mongodb+srv://<user>:<password>@cluster0-fqsfu.mongodb.net/test?retryWrites=true&amp;w=majority</entry>

Obviously user and passowrd are not shown. If anyone could accomplish , please share it , thanks