From f9fb4c1bc58ee3a781a83204b6058427e183e1ca Mon Sep 17 00:00:00 2001 From: Mark Carrington Date: Wed, 1 Aug 2018 22:32:04 +0100 Subject: [PATCH 1/2] Include `rate` property in temp basal records --- .../androidaps/plugins/NSClientInternal/NSUpload.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java index e1f9535caa..c15d5164e0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java @@ -57,6 +57,7 @@ public class NSUpload { data.put("eventType", CareportalEvent.TEMPBASAL); data.put("duration", temporaryBasal.durationInMinutes); data.put("absolute", temporaryBasal.absoluteRate); + data.put("rate", temporaryBasal.absoluteRate); if (temporaryBasal.pumpId != 0) data.put("pumpId", temporaryBasal.pumpId); data.put("created_at", DateUtil.toISOString(temporaryBasal.date)); @@ -81,12 +82,16 @@ public class NSUpload { try { SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); boolean useAbsolute = SP.getBoolean("ns_sync_use_absolute", false); + Profile profile = ProfileFunctions.getInstance().getProfile(); + double absoluteRate = 0; + if (profile != null) { + absoluteRate = profile.getBasal(temporaryBasal.date) * temporaryBasal.percentRate / 100d; + } if (useAbsolute) { TemporaryBasal t = temporaryBasal.clone(); t.isAbsolute = true; - Profile profile = ProfileFunctions.getInstance().getProfile(); if (profile != null) { - t.absoluteRate = profile.getBasal(temporaryBasal.date) * temporaryBasal.percentRate / 100d; + t.absoluteRate = absoluteRate; uploadTempBasalStartAbsolute(t, null); } } else { @@ -95,6 +100,8 @@ public class NSUpload { data.put("eventType", CareportalEvent.TEMPBASAL); data.put("duration", temporaryBasal.durationInMinutes); data.put("percent", temporaryBasal.percentRate - 100); + if (profile != null) + data.put("rate", absoluteRate); if (temporaryBasal.pumpId != 0) data.put("pumpId", temporaryBasal.pumpId); data.put("created_at", DateUtil.toISOString(temporaryBasal.date)); From 7be49571ae200036ba3d1c1f0a3c7adb7e539e4d Mon Sep 17 00:00:00 2001 From: Mark Carrington Date: Thu, 2 Aug 2018 12:27:56 +0100 Subject: [PATCH 2/2] Get profile for specific time for percentage -> absolute conversion --- .../androidaps/plugins/NSClientInternal/NSUpload.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java index c15d5164e0..314ee38972 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java @@ -82,7 +82,7 @@ public class NSUpload { try { SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); boolean useAbsolute = SP.getBoolean("ns_sync_use_absolute", false); - Profile profile = ProfileFunctions.getInstance().getProfile(); + Profile profile = ProfileFunctions.getInstance().getProfile(temporaryBasal.date); double absoluteRate = 0; if (profile != null) { absoluteRate = profile.getBasal(temporaryBasal.date) * temporaryBasal.percentRate / 100d;