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
Branches
Tags
No related merge requests found
...@@ -39,6 +39,7 @@ import info.nightscout.android.utils.ConfigurationStore; ...@@ -39,6 +39,7 @@ import info.nightscout.android.utils.ConfigurationStore;
import info.nightscout.android.utils.DataStore; import info.nightscout.android.utils.DataStore;
import info.nightscout.android.xdrip_plus.XDripPlusUploadReceiver; import info.nightscout.android.xdrip_plus.XDripPlusUploadReceiver;
import io.realm.Realm; import io.realm.Realm;
import io.realm.RealmResults;
public class MedtronicCnlIntentService extends IntentService { public class MedtronicCnlIntentService extends IntentService {
public final static int USB_VID = 0x1a79; public final static int USB_VID = 0x1a79;
...@@ -245,15 +246,12 @@ public class MedtronicCnlIntentService extends IntentService { ...@@ -245,15 +246,12 @@ public class MedtronicCnlIntentService extends IntentService {
sendStatus("Pump sent old SGV event, re-polling..."); 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 dataStore.clearUnavailableSGVCount(); // reset unavailable sgv count
// Check that the record doesn't already exist before committing // Check that the record doesn't already exist before committing
RealmResults<PumpStatusEvent> checkExistingRecords = activePump.getPumpHistory() RealmResults<PumpStatusEvent> checkExistingRecords = activePump.getPumpHistory()
.where() .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()) .equalTo("sgv", pumpRecord.getSgv())
.findAll(); .findAll();
......
...@@ -81,7 +81,7 @@ public class EntriesSerializer implements JsonSerializer<PumpStatusEvent> { ...@@ -81,7 +81,7 @@ public class EntriesSerializer implements JsonSerializer<PumpStatusEvent> {
jsonObject.addProperty("device", src.getDeviceName()); jsonObject.addProperty("device", src.getDeviceName());
jsonObject.addProperty("type", "sgv"); jsonObject.addProperty("type", "sgv");
jsonObject.addProperty("date", src.getSgvDate().getTime()); jsonObject.addProperty("date", src.getSgvDate().getTime());
jsonObject.addProperty("dateString", String.valueOf(src.getEventDate())); jsonObject.addProperty("dateString", String.valueOf(src.getSgvDate()));
return jsonObject; return jsonObject;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment