Skip to content
Snippets Groups Projects
Unverified Commit f182e8e9 authored by Johannes Mockenhaupt's avatar Johannes Mockenhaupt
Browse files

Bugfix: use sgvDate to detect possible duplicate.

parent 2df004a0
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@ import info.nightscout.android.utils.ConfigurationStore;
import info.nightscout.android.utils.DataStore;
import info.nightscout.android.xdrip_plus.XDripPlusUploadReceiver;
import io.realm.Realm;
import io.realm.RealmResults;
public class MedtronicCnlIntentService extends IntentService {
public final static int USB_VID = 0x1a79;
......@@ -245,15 +246,12 @@ public class MedtronicCnlIntentService extends IntentService {
sendStatus("Pump sent old SGV event, re-polling...");
}
//MainActivity.timeLastGoodSGV = pumpRecord.getEventDate().getTime(); // track last good sgv event time
//MainActivity.pumpBattery = pumpRecord.getBatteryPercentage(); // track pump battery
timeLastGoodSGV = pumpRecord.getEventDate().getTime();
dataStore.clearUnavailableSGVCount(); // reset unavailable sgv count
// Check that the record doesn't already exist before committing
RealmResults<PumpStatusEvent> checkExistingRecords = activePump.getPumpHistory()
.where()
.equalTo("eventDate", pumpRecord.getEventDate()) // >>>>>>> check as event date may not = exact pump event date due to it being stored with offset added this could lead to dup events due to slight variability in time offset
.equalTo("sgvDate", pumpRecord.getSgvDate())
.equalTo("sgv", pumpRecord.getSgv())
.findAll();
......
......@@ -81,7 +81,7 @@ public class EntriesSerializer implements JsonSerializer<PumpStatusEvent> {
jsonObject.addProperty("device", src.getDeviceName());
jsonObject.addProperty("type", "sgv");
jsonObject.addProperty("date", src.getSgvDate().getTime());
jsonObject.addProperty("dateString", String.valueOf(src.getEventDate()));
jsonObject.addProperty("dateString", String.valueOf(src.getSgvDate()));
return jsonObject;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment