From 62cb1bb5062af08ea26846d8cfdb9b5b3d24c0cf Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 26 Jun 2021 19:53:09 +0200 Subject: [PATCH 1/5] reduce warnings amount --- .../androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt | 5 ++++- .../androidaps/plugins/pump/PumpSyncImplementation.kt | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt index 8d57e4f789..db3b2bf517 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt @@ -134,7 +134,10 @@ class ConfigBuilderPlugin @Inject constructor( // Ask when switching to physical pump plugin fun switchAllowed(changedPlugin: PluginBase, newState: Boolean, activity: FragmentActivity?, type: PluginType) { - if (changedPlugin.getType() == PluginType.PUMP && changedPlugin.name != resourceHelper.gs(R.string.virtualpump)) confirmPumpPluginActivation(changedPlugin, newState, activity, type) else performPluginSwitch(changedPlugin, newState, type) + if (changedPlugin.getType() == PluginType.PUMP && changedPlugin.name != resourceHelper.gs(R.string.virtualpump)) + confirmPumpPluginActivation(changedPlugin, newState, activity, type) + else if (changedPlugin.getType() == PluginType.PUMP) pumpSync.connectNewPump() + else performPluginSwitch(changedPlugin, newState, type) } private fun confirmPumpPluginActivation(changedPlugin: PluginBase, newState: Boolean, activity: FragmentActivity?, type: PluginType) { diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt b/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt index 842381fd03..ba1609c579 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt @@ -68,7 +68,7 @@ class PumpSyncImplementation @Inject constructor( return true } - if (type.description != storedType || serialNumber != storedSerial) + if ((type.description != storedType || serialNumber != storedSerial) && timestamp >= storedTimestamp) rxBus.send(EventNewNotification(Notification(Notification.WRONG_PUMP_DATA, resourceHelper.gs(R.string.wrong_pump_data), Notification.URGENT))) aapsLogger.error(LTag.PUMP, "Ignoring pump history record Allowed: ${dateUtil.dateAndTimeAndSecondsString(storedTimestamp)} $storedType $storedSerial Received: $timestamp ${dateUtil.dateAndTimeAndSecondsString(timestamp)} ${type.description} $serialNumber") return false From 49776c8872d67cc509074b1cddbfb466456bf155 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 26 Jun 2021 20:54:13 +0200 Subject: [PATCH 2/5] remove unused import --- .../main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt b/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt index 609b70a01e..a5ccaa2b41 100644 --- a/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt +++ b/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt @@ -17,7 +17,6 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.services.AlarmSoundServiceHelper import info.nightscout.androidaps.utils.T -import org.mozilla.javascript.tools.jsc.Main import javax.inject.Inject class ErrorDialog : DaggerDialogFragment() { From e08af1e7e45eeffeff347bda81139b42a0e7237b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 26 Jun 2021 22:15:02 +0200 Subject: [PATCH 3/5] fix NS sync issue --- .../UpdateNsIdBolusCalculatorResultTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdBolusTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdCarbsTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdDeviceStatusTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdExtendedBolusTransaction.kt | 6 ++++-- .../database/transactions/UpdateNsIdFoodTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdGlucoseValueTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdOfflineEventTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdProfileSwitchTransaction.kt | 6 ++++-- .../UpdateNsIdTemporaryBasalTransaction.kt | 10 ++++++---- .../UpdateNsIdTemporaryTargetTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdTherapyEventTransaction.kt | 6 ++++-- 12 files changed, 50 insertions(+), 26 deletions(-) diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusCalculatorResultTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusCalculatorResultTransaction.kt index da50ce0a55..b824e1b4f4 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusCalculatorResultTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusCalculatorResultTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdBolusCalculatorResultTransaction(val bolusCalculatorResult: Bolu override fun run() { val current = database.bolusCalculatorResultDao.findById(bolusCalculatorResult.id) - if (current != null && current.interfaceIDs.nightscoutId != bolusCalculatorResult.interfaceIDs.nightscoutId) - database.bolusCalculatorResultDao.updateExistingEntry(bolusCalculatorResult) + if (current != null && current.interfaceIDs.nightscoutId != bolusCalculatorResult.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = bolusCalculatorResult.interfaceIDs.nightscoutId + database.bolusCalculatorResultDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusTransaction.kt index a6e0a574ff..2504545419 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdBolusTransaction(val bolus: Bolus) : Transaction() { override fun run() { val current = database.bolusDao.findById(bolus.id) - if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId) - database.bolusDao.updateExistingEntry(bolus) + if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = bolus.interfaceIDs.nightscoutId + database.bolusDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdCarbsTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdCarbsTransaction.kt index 2cba4540f9..9595fd3a17 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdCarbsTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdCarbsTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdCarbsTransaction(val carbs: Carbs) : Transaction() { override fun run() { val current = database.carbsDao.findById(carbs.id) - if (current != null && current.interfaceIDs.nightscoutId != carbs.interfaceIDs.nightscoutId) - database.carbsDao.updateExistingEntry(carbs) + if (current != null && current.interfaceIDs.nightscoutId != carbs.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = carbs.interfaceIDs.nightscoutId + database.carbsDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdDeviceStatusTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdDeviceStatusTransaction.kt index 766f672877..159992ba5f 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdDeviceStatusTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdDeviceStatusTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdDeviceStatusTransaction(val deviceStatus: DeviceStatus) : Transa override fun run() { val current = database.deviceStatusDao.findById(deviceStatus.id) - if (current != null && current.interfaceIDs.nightscoutId != deviceStatus.interfaceIDs.nightscoutId) - database.deviceStatusDao.update(deviceStatus) + if (current != null && current.interfaceIDs.nightscoutId != deviceStatus.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = deviceStatus.interfaceIDs.nightscoutId + database.deviceStatusDao.update(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdExtendedBolusTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdExtendedBolusTransaction.kt index cfa12027b1..cc174ad734 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdExtendedBolusTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdExtendedBolusTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdExtendedBolusTransaction(val bolus: ExtendedBolus) : Transaction override fun run() { val current = database.extendedBolusDao.findById(bolus.id) - if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId) - database.extendedBolusDao.updateExistingEntry(bolus) + if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = bolus.interfaceIDs.nightscoutId + database.extendedBolusDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdFoodTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdFoodTransaction.kt index e03e38e343..78179c8cb8 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdFoodTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdFoodTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdFoodTransaction(val food: Food) : Transaction() { override fun run() { val current = database.foodDao.findById(food.id) - if (current != null && current.interfaceIDs.nightscoutId != food.interfaceIDs.nightscoutId) - database.foodDao.updateExistingEntry(food) + if (current != null && current.interfaceIDs.nightscoutId != food.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = food.interfaceIDs.nightscoutId + database.foodDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdGlucoseValueTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdGlucoseValueTransaction.kt index 954aadd39b..3b43b92943 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdGlucoseValueTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdGlucoseValueTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdGlucoseValueTransaction(val glucoseValue: GlucoseValue) : Transa override fun run() { val current = database.glucoseValueDao.findById(glucoseValue.id) - if (current != null && current.interfaceIDs.nightscoutId != glucoseValue.interfaceIDs.nightscoutId) - database.glucoseValueDao.updateExistingEntry(glucoseValue) + if (current != null && current.interfaceIDs.nightscoutId != glucoseValue.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = glucoseValue.interfaceIDs.nightscoutId + database.glucoseValueDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdOfflineEventTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdOfflineEventTransaction.kt index ebb19ce486..3da1b26ce7 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdOfflineEventTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdOfflineEventTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdOfflineEventTransaction(val offlineEvent: OfflineEvent) : Transa override fun run() { val current = database.offlineEventDao.findById(offlineEvent.id) - if (current != null && current.interfaceIDs.nightscoutId != offlineEvent.interfaceIDs.nightscoutId) - database.offlineEventDao.updateExistingEntry(offlineEvent) + if (current != null && current.interfaceIDs.nightscoutId != offlineEvent.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = offlineEvent.interfaceIDs.nightscoutId + database.offlineEventDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdProfileSwitchTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdProfileSwitchTransaction.kt index 63a589db51..368a66dc3f 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdProfileSwitchTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdProfileSwitchTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdProfileSwitchTransaction(val profileSwitch: ProfileSwitch) : Tra override fun run() { val current = database.profileSwitchDao.findById(profileSwitch.id) - if (current != null && current.interfaceIDs.nightscoutId != profileSwitch.interfaceIDs.nightscoutId) - database.profileSwitchDao.updateExistingEntry(profileSwitch) + if (current != null && current.interfaceIDs.nightscoutId != profileSwitch.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = profileSwitch.interfaceIDs.nightscoutId + database.profileSwitchDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryBasalTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryBasalTransaction.kt index be9a3c3efa..571f3da027 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryBasalTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryBasalTransaction.kt @@ -2,11 +2,13 @@ package info.nightscout.androidaps.database.transactions import info.nightscout.androidaps.database.entities.TemporaryBasal -class UpdateNsIdTemporaryBasalTransaction(val bolus: TemporaryBasal) : Transaction() { +class UpdateNsIdTemporaryBasalTransaction(val temporaryBasal: TemporaryBasal) : Transaction() { override fun run() { - val current = database.temporaryBasalDao.findById(bolus.id) - if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId) - database.temporaryBasalDao.updateExistingEntry(bolus) + val current = database.temporaryBasalDao.findById(temporaryBasal.id) + if (current != null && current.interfaceIDs.nightscoutId != temporaryBasal.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = temporaryBasal.interfaceIDs.nightscoutId + database.temporaryBasalDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryTargetTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryTargetTransaction.kt index 419fba854d..28bd4211d6 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryTargetTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryTargetTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdTemporaryTargetTransaction(val temporaryTarget: TemporaryTarget) override fun run() { val current = database.temporaryTargetDao.findById(temporaryTarget.id) - if (current != null && current.interfaceIDs.nightscoutId != temporaryTarget.interfaceIDs.nightscoutId) - database.temporaryTargetDao.updateExistingEntry(temporaryTarget) + if (current != null && current.interfaceIDs.nightscoutId != temporaryTarget.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = temporaryTarget.interfaceIDs.nightscoutId + database.temporaryTargetDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTherapyEventTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTherapyEventTransaction.kt index 680fbe7ca3..0f04c6f81d 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTherapyEventTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTherapyEventTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdTherapyEventTransaction(val therapyEvent: TherapyEvent) : Transa override fun run() { val current = database.therapyEventDao.findById(therapyEvent.id) - if (current != null && current.interfaceIDs.nightscoutId != therapyEvent.interfaceIDs.nightscoutId) - database.therapyEventDao.updateExistingEntry(therapyEvent) + if (current != null && current.interfaceIDs.nightscoutId != therapyEvent.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = therapyEvent.interfaceIDs.nightscoutId + database.therapyEventDao.updateExistingEntry(current) + } } } \ No newline at end of file From dc90c6b140e9df77b5739ba1ccd32a951cc83bae Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 26 Jun 2021 22:52:51 +0200 Subject: [PATCH 4/5] fix switching to virtual pump --- .../androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt index db3b2bf517..dce8c55206 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt @@ -136,8 +136,10 @@ class ConfigBuilderPlugin @Inject constructor( fun switchAllowed(changedPlugin: PluginBase, newState: Boolean, activity: FragmentActivity?, type: PluginType) { if (changedPlugin.getType() == PluginType.PUMP && changedPlugin.name != resourceHelper.gs(R.string.virtualpump)) confirmPumpPluginActivation(changedPlugin, newState, activity, type) - else if (changedPlugin.getType() == PluginType.PUMP) pumpSync.connectNewPump() - else performPluginSwitch(changedPlugin, newState, type) + else if (changedPlugin.getType() == PluginType.PUMP) { + performPluginSwitch(changedPlugin, newState, type) + pumpSync.connectNewPump() + } else performPluginSwitch(changedPlugin, newState, type) } private fun confirmPumpPluginActivation(changedPlugin: PluginBase, newState: Boolean, activity: FragmentActivity?, type: PluginType) { From cf006790b95f5d498cb8359a96841b0dbfffcc8e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 26 Jun 2021 22:57:40 +0200 Subject: [PATCH 5/5] make automation profile switch based on last profile switch instead of profile store --- .../ProfileFunctionImplementation.kt | 26 ++++++++++++++++--- .../androidaps/database/AppRepository.kt | 5 ++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt index 4440eda924..3de63dbbd5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt @@ -117,9 +117,27 @@ class ProfileFunctionImplementation @Inject constructor( } override fun createProfileSwitch(durationInMinutes: Int, percentage: Int, timeShiftInHours: Int) { - val profileStore = activePlugin.activeProfileSource.profile ?: return - val profileName = activePlugin.activeProfileSource.profile?.getDefaultProfileName() - ?: return - createProfileSwitch(profileStore, profileName, durationInMinutes, percentage, timeShiftInHours, dateUtil.now()) + val profile = repository.getPermanentProfileSwitch(dateUtil.now()) + ?: throw InvalidParameterSpecException("No active ProfileSwitch") + val ps = ProfileSwitch( + timestamp = dateUtil.now(), + basalBlocks = profile.basalBlocks, + isfBlocks = profile.isfBlocks, + icBlocks = profile.icBlocks, + targetBlocks = profile.targetBlocks, + glucoseUnit = profile.glucoseUnit, + profileName = profile.profileName, + timeshift = T.hours(timeShiftInHours.toLong()).msecs(), + percentage = percentage, + duration = T.mins(durationInMinutes.toLong()).msecs(), + insulinConfiguration = activePlugin.activeInsulin.insulinConfiguration + ) + disposable += repository.runTransactionForResult(InsertOrUpdateProfileSwitch(ps)) + .subscribe({ result -> + result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted ProfileSwitch $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated ProfileSwitch $it") } + }, { + aapsLogger.error(LTag.DATABASE, "Error while saving ProfileSwitch", it) + }) } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/AppRepository.kt b/database/src/main/java/info/nightscout/androidaps/database/AppRepository.kt index da7449f887..11754adf03 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/AppRepository.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/AppRepository.kt @@ -213,6 +213,11 @@ open class AppRepository @Inject internal constructor( return null } + fun getPermanentProfileSwitch(timestamp: Long): ProfileSwitch? = + database.profileSwitchDao.getPermanentProfileSwitchActiveAt(timestamp) + .subscribeOn(Schedulers.io()) + .blockingGet() + fun getAllProfileSwitches(): Single> = database.profileSwitchDao.getAllProfileSwitches() .subscribeOn(Schedulers.io())