Merge pull request #2309 from andyrozman/bug_2292_doublebolus_again

- added code to remove Treatment entries, without any insulin (for sy…
This commit is contained in:
Milos Kozak 2019-12-25 11:29:15 +01:00 committed by GitHub
commit 967777f0f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,6 +32,7 @@ import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder;
@ -613,6 +614,8 @@ public class MedtronicHistoryData {
return;
}
filterOutNonInsulinEntries(entriesFromHistory);
if (doubleBolusDebug)
LOG.debug("DoubleBolusDebug: List (after filter): {}, FromDb={}", gson.toJson(entryList),
gsonCore.toJson(entriesFromHistory));
@ -640,6 +643,23 @@ public class MedtronicHistoryData {
}
private void filterOutNonInsulinEntries(List<? extends DbObjectBase> entriesFromHistory) {
// when we try to pair PumpHistory with AAPS treatments, we need to ignore all non-insulin entries
List<DbObjectBase> removeList = new ArrayList<>();
for (DbObjectBase dbObjectBase : entriesFromHistory) {
Treatment treatment = (Treatment)dbObjectBase;
if (RileyLinkUtil.isSame(treatment.insulin, 0d)) {
removeList.add(dbObjectBase);
}
}
entriesFromHistory.removeAll(removeList);
}
private void processTBREntries(List<PumpHistoryEntry> entryList) {
Collections.reverse(entryList);