optimize query if TBR is not faked by EB

This commit is contained in:
Milos Kozak 2021-10-03 11:37:23 +02:00
parent de842ce1ee
commit 29acc3d17f

View file

@ -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
}