rodrigojmlourenco / TrackerProto

Prototype for the TRACE Tracker App
0 stars 0 forks source link

Tracks are being uploaded twice #9

Closed rodrigojmlourenco closed 8 years ago

rodrigojmlourenco commented 8 years ago

In a brief analysis of the uploaded sessions metadata, i can observe that the replica is almost consistently uploaded 4 seconds later.

+------------------------------------------------------------------+--------+----------+---------------------+----------+
| Session                                                          | UserId | IsClosed | CreatedAt           | Distance |
+------------------------------------------------------------------+--------+----------+---------------------+----------+
| 26e93f9f6e580b11fb352ab68b7a292c512f9639be3838e629a3ddfb4b5abb6f |      1 |        0 | 2016-07-15 09:26:24 |        0 |
| 78c712e39043f8e8ffc38f9fb78a546e16e737cc2b54f78995671158749f6d81 |      1 |        0 | 2016-07-15 09:26:20 |        0 |
| f778bb9fc0c5c9dfaf8798a83f938cbc9abeafb3952c3ddff7a7ab7722461c5f |      1 |        0 | 2016-07-14 19:15:25 |        0 |
| a79ba872036a74cc56a4ddbc13b06d53084787870607e2d2171abd50c23b8de8 |      1 |        0 | 2016-07-14 19:15:22 |        0 |
rodrigojmlourenco commented 8 years ago

It is possible that the problem was at the application's level. Once the tracking was stopped the track was saved locally in the RouteCache@store-client, however, the track was not deleted in the tracker.

The new code version is now:

private void storeTrackAsRoute(Track track){
        Route route = new Route();
        String authToken = ((AuthenticationTokenHolder)getActivity()).getAuthenticationToken();

        // The track is converted into a route here

        try {
            mRouteCache.saveRoute(authToken, route);
            mTracker.deleteTracedTrack(track.getTrackId()); //!NEW!
        } catch (UnableToCreateRouteCopyException e) {
            throw new RuntimeException(e.getMessage());
        }
    }