question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

why getValidLocations() method gives duplicate data ?

See original GitHub issue

I am using getValidLocations() method for retrieved stored location and push to server. after pushed i used deleteAllLocations() method for delete stored locations.

But many times getValidLocations() method gives me duplicate data , i think its due to plugin updates location two times at same time.

Your Environment

  • Plugin version: 2.3.5

  • Platform: iOS

  • OS version: 10.2.1

  • Device manufacturer and model: iPhone 5s

  • Cordova version (cordova -v): 8.0.0

  • Cordova platform version (cordova platform ls): 4.5.4

  • Plugin configuration options: let config = { desiredAccuracy: 0, stationaryRadius: 50, distanceFilter: 200, notificationTitle: 'XYZ', notificationText: 'ENABLED', foregroundService: true, debug: true, locationProvider: 1, interval: 120000, fastestInterval: 120000, url: 'http://....', httpHeaders: { "Content-Type": "application/json" }, postTemplate: { "UserId": this.UserId, "LocationData": [ { "Lat": this.lat, "Long": this.lng, "Date": this.cuuDate, "BatteryPerc": this.batteryLevel } ] }, method: 'POST', autoSync: true, saveBatteryOnBackground: false, stopOnTerminate: false, startOnBoot: true };

  • Link to your project:

Context

getValidLocations() method gives duplicate entry.

Expected Behavior

i think , its due to plugin updates two or three times at same time

Actual Behavior

Possible Fix

Steps to Reproduce

Context

Debug logs

My Code is Below… ` startBackgroundLocation() {

      this.UserId = 4

    let config = {

desiredAccuracy: 0, stationaryRadius: 50, distanceFilter: 200, notificationTitle: ‘XYZ’, notificationText: ‘ENABLED’, foregroundService: true, debug: true, locationProvider: 1, interval: 120000, fastestInterval: 120000, url: ‘http://…’, httpHeaders: { “Content-Type”: “application/json” }, postTemplate: { “UserId”: this.UserId, “LocationData”: [ { “Lat”: this.lat, “Long”: this.lng, “Date”: this.cuuDate, “BatteryPerc”: this.batteryLevel } ] }, method: ‘POST’, autoSync: true, saveBatteryOnBackground: false, stopOnTerminate: false, startOnBoot: true }; this.backgroundGeolocation.configure(config).subscribe((location) => {

           console.log('configuration: '+JSON.stringify(location));

           console.log('Lat: '+location.latitude + ' :: '+location.longitude );

           this.lat = location.latitude;
           this.lng = location.longitude;

           this.cuuDate = new Date();
           this.cuuDate = moment(this.cuuDate).format('YYYY-MM-DDTHH:mm:ss');
           console.log('current date and time : '+this.cuuDate);
           const subscription = this.batteryStatus.onChange().subscribe(status => {
               console.log(status.level, status.isPlugged);
               this.batteryLevel = status.level;
           });

           if( this.httpService.isOnline() ) {
               this.arrLocations = [];
               // this.arrLocations = this.dbHandlerProvider.get_location();
               this.backgroundGeolocation.getValidLocations().then(res=> {
                    // this.arrLocations = res;
                    console.log('Background getValidLocations: '+JSON.stringify(res));
                    for(let i=0; i<res.length; i++) {
                        var millisec = new Date(res[i].time);
                        var milliInDate = moment(millisec).format('YYYY-MM-DDTHH:mm:ss');
                        if(this.arrLocations.indexOf(res[i].latitude) != -1 && this.arrLocations.indexOf(res[i].longitude) != -1 && this.arrLocations.indexOf(res[i].milliInDate) != -1 ) {
                        } else {
                            this.arrLocations.push({
                                Lat: res[i].latitude,
                                Long: res[i].longitude,
                                Date: milliInDate,
                                BatteryPerc: this.batteryLevel
                            });
                        }
                    }
                    setTimeout(()=> {
                        console.log('Back Location Data: '+JSON.stringify(this.arrLocations));
                        this.serverPush.pushPosition({
                            UserId: this.UserId,
                            LocationData: this.arrLocations
                        });
                    },2000);
               });
       } else {
           // this.dbHandlerProvider.add_location(this.lat,this.lng,this.cuuDate,11);
       }
       this.backgroundGeolocation.finish();

   }, (err) => {
     console.log(err);
   });

   this.backgroundGeolocation.start();

}`

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:21 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
aaronharper123commented, Jun 11, 2018

i am getting all stored location in the time of interval and delete records after pushed to server. but all time , i get duplicate entries 3-4 times.

please check my logs below

[{“provider”:“fused”,“time”:1528714195154,“latitude”:23.0401284,“longitude”:72.5188049,“accuracy”:30.132999420166016,“locationProvider”:1,“locationId”:4}]

[{“provider”:“fused”,“time”:1528714195154,“latitude”:23.0401284,“longitude”:72.5188049,“accuracy”:30.132999420166016,“locationProvider”:1,“locationId”:4}]

[{“provider”:“fused”,“time”:1528714195154,“latitude”:23.0401284,“longitude”:72.5188049,“accuracy”:30.132999420166016,“locationProvider”:1,“locationId”:4}]

0reactions
stale[bot]commented, Dec 22, 2018

This issue has been automatically closed, because it has not had recent activity. If you believe this issue shouldn’t be closed, please reopen or write down a comment requesting issue reopening with explanation why you think it’s important. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling duplicate data in streaming pipeline using Pub/Sub ...
This section gives an overview of the places where duplicate data may originate in your streaming pipelines. Numbers in red boxes in the ......
Read more >
How To Deal with Duplicate Entries Using SQL
A 3-step approach to tackle the problem of duplicates in databases ... Duplicates are a recurring problem for any database user. There are...
Read more >
Prevent duplicate values in a table field using an index
Set the field's Indexed property to Yes (No duplicates) You can do this by opening the table in Design view. This method is...
Read more >
Identifying and removing duplicate records from systematic ...
Objective. The purpose of this study was to compare effectiveness of different options for de-duplicating records retrieved from systematic review searches.
Read more >
Identify and Remove Duplicate Data in R - Datanovia
distinct() [dplyr package] to remove duplicate rows in a data frame. ... Following this way, you can remove duplicate rows from a data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found