From 29acc3d17f34bcafd7812205bc179a28e91cb212 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 3 Oct 2021 11:37:23 +0200 Subject: [PATCH] optimize query if TBR is not faked by EB --- .../iob/iobCobCalculator/IobCobCalculatorPlugin.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt index 4cad7c1f92..3ecfbc1f86 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt @@ -510,10 +510,11 @@ class IobCobCalculatorPlugin @Inject constructor( val tb = repository.getTemporaryBasalActiveAt(timestamp).blockingGet() if (tb is ValueWrapper.Existing) return tb.value - val eb = repository.getExtendedBolusActiveAt(timestamp).blockingGet() - val profile = profileFunction.getProfile(timestamp) ?: return null - if (eb is ValueWrapper.Existing && activePlugin.activePump.isFakingTempsByExtendedBoluses) - return eb.value.toTemporaryBasal(profile) + if (activePlugin.activePump.isFakingTempsByExtendedBoluses) { + val eb = repository.getExtendedBolusActiveAt(timestamp).blockingGet() + val profile = profileFunction.getProfile(timestamp) ?: return null + if (eb is ValueWrapper.Existing) return eb.value.toTemporaryBasal(profile) + } return null }