From edd5dd7980cbeeb349179494121375ed22e148d3 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 12 Nov 2020 22:56:03 +0100 Subject: [PATCH] fix Stats --- .../info/nightscout/androidaps/utils/stats/TddCalculator.kt | 2 +- .../nightscout/androidaps/interfaces/ProfileFunction.kt | 1 + .../plugins/configBuilder/ProfileFunctionImplementation.kt | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt index 6cecfa4f73..a11b53464a 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt @@ -62,7 +62,7 @@ class TddCalculator @Inject constructor( val midnight = MidnightTime.calc(t) val tdd = result[midnight] ?: TDD(midnight, 0.0, 0.0, 0.0) val tbr = getTempBasalFromHistory(t) - val profile = profileFunction.getProfile(t) ?: continue + val profile = profileFunction.getProfile(t, this) ?: continue val absoluteRate = tbr?.tempBasalConvertedToAbsolute(t, profile) ?: profile.getBasal(t) tdd.basal += absoluteRate / 60.0 * 5.0 diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileFunction.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileFunction.kt index 64582a62d9..bab94ab5c4 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileFunction.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileFunction.kt @@ -13,5 +13,6 @@ interface ProfileFunction { fun getProfile(): Profile? fun getUnits(): String fun getProfile(time: Long): Profile? + fun getProfile(time: Long, activeTreatments: TreatmentsInterface): Profile? fun prepareProfileSwitch(profileStore: ProfileStore, profileName: String, duration: Int, percentage: Int, timeShift: Int, date: Long): ProfileSwitch } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt index ed084120f4..6156142755 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt @@ -11,6 +11,7 @@ import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.interfaces.ProfileStore import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.interfaces.TreatmentsInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.FabricPrivacy @@ -70,8 +71,9 @@ class ProfileFunctionImplementation @Inject constructor( override fun getProfile(): Profile? = getProfile(System.currentTimeMillis()) - override fun getProfile(time: Long): Profile? { - val activeTreatments = activePlugin.activeTreatments + override fun getProfile(time: Long): Profile? = getProfile(time, activePlugin.activeTreatments) + + override fun getProfile(time: Long, activeTreatments: TreatmentsInterface): Profile? { val activeProfile = activePlugin.activeProfileInterface //log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time));