diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt index c18c1128a3..e3271f0c32 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt @@ -16,6 +16,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.PluginStore import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefs +import info.nightscout.androidaps.plugins.general.nsclient.DataSyncSelectorImplementation import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin @@ -85,6 +86,8 @@ open class AppModule { @Binds fun bindIobCobCalculatorInterface(iobCobCalculatorPlugin: IobCobCalculatorPlugin): IobCobCalculatorInterface @Binds fun bindSmsCommunicatorInterface(smsCommunicatorPlugin: SmsCommunicatorPlugin): SmsCommunicatorInterface @Binds fun bindUploadQueueAdminInterfaceToUploadQueue(uploadQueueAdminInterface: UploadQueueAdminInterface) : UploadQueueInterface + @Binds fun bindDataSyncSelector(dataSyncSelectorImplementation: DataSyncSelectorImplementation): DataSyncSelector + } } diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DataClassesModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DataClassesModule.kt index de4df287a4..c222f2de55 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DataClassesModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DataClassesModule.kt @@ -14,7 +14,7 @@ abstract class DataClassesModule { @ContributesAndroidInjector abstract fun glucoseStatusInjector(): GlucoseStatus - @ContributesAndroidInjector abstract fun DatabaseHelperInjector(): DatabaseHelper + @ContributesAndroidInjector abstract fun databaseHelperInjector(): DatabaseHelper @ContributesAndroidInjector abstract fun treatmentServiceInjector(): TreatmentService @ContributesAndroidInjector abstract fun bolusWizardInjector(): BolusWizard diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt index c0eadc1b56..87a0c99e55 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -25,7 +25,6 @@ import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.queue.Callback @@ -51,7 +50,6 @@ class CarbsDialog : DialogFragmentWithDate() { @Inject lateinit var treatmentsPlugin: TreatmentsPlugin @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin - @Inject lateinit var nsUpload: NSUpload @Inject lateinit var uel: UserEntryLogger @Inject lateinit var carbTimer: CarbTimer @Inject lateinit var commandQueue: CommandQueue @@ -234,16 +232,10 @@ class CarbsDialog : DialogFragmentWithDate() { lowTarget = Profile.toMgdl(activityTT, profileFunction.getUnits()), highTarget = Profile.toMgdl(activityTT, profileFunction.getUnits()) )).subscribe({ result -> - result.inserted.forEach { - aapsLogger.debug(LTag.DATABASE, "Inserted tt $it") - nsUpload.uploadTempTarget(it) - } - result.updated.forEach { - aapsLogger.debug(LTag.DATABASE, "Updated tt $it") - nsUpload.updateTempTarget(it) - } + result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it) + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) }) } @@ -256,16 +248,10 @@ class CarbsDialog : DialogFragmentWithDate() { lowTarget = Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()), highTarget = Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()) )).subscribe({ result -> - result.inserted.forEach { - aapsLogger.debug(LTag.DATABASE, "Inserted tt $it") - nsUpload.uploadTempTarget(it) - } - result.updated.forEach { - aapsLogger.debug(LTag.DATABASE, "Updated tt $it") - nsUpload.updateTempTarget(it) - } + result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it) + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) }) } @@ -278,14 +264,8 @@ class CarbsDialog : DialogFragmentWithDate() { lowTarget = Profile.toMgdl(hypoTT, profileFunction.getUnits()), highTarget = Profile.toMgdl(hypoTT, profileFunction.getUnits()) )).subscribe({ result -> - result.inserted.forEach { - aapsLogger.debug(LTag.DATABASE, "Inserted tt $it") - nsUpload.uploadTempTarget(it) - } - result.updated.forEach { - aapsLogger.debug(LTag.DATABASE, "Updated tt $it") - nsUpload.updateTempTarget(it) - } + result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } }, { aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) }) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt index 9e84b39f7a..ec7a9c4d1a 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -227,7 +227,7 @@ class CareDialog : DialogFragmentWithDate() { disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(therapyEvent)).subscribe({ result -> result.inserted.forEach { nsUpload.uploadEvent(it) } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving therapy event", it) + aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) }) valuesWithUnit.add(0, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged)) valuesWithUnit.add(1, ValueWithUnit(therapyEvent.type.text, Units.TherapyEvent)) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt index 7327691855..90eeeb7f52 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -150,7 +150,7 @@ class FillDialog : DialogFragmentWithDate() { )).subscribe({ result -> result.inserted.forEach { nsUpload.uploadEvent(it) } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving therapy event", it) + aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) }) } if (insulinChange) { @@ -164,7 +164,7 @@ class FillDialog : DialogFragmentWithDate() { )).subscribe({ result -> result.inserted.forEach { nsUpload.uploadEvent(it) } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving therapy event", it) + aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) }) } }, null) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt index 4fe211c3c2..a88819b604 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -197,16 +197,10 @@ class InsulinDialog : DialogFragmentWithDate() { lowTarget = Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()), highTarget = Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()) )).subscribe({ result -> - result.inserted.forEach { - aapsLogger.debug(LTag.DATABASE, "Inserted tt $it") - nsUpload.uploadTempTarget(it) - } - result.updated.forEach { - aapsLogger.debug(LTag.DATABASE, "Updated tt $it") - nsUpload.updateTempTarget(it) - } + result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it) + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) }) } if (insulinAfterConstraints > 0) { @@ -229,7 +223,7 @@ class InsulinDialog : DialogFragmentWithDate() { nsUpload.uploadBolusRecord(it, detailedBolusInfo.createTherapyEvent(), null) } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving bolus", it) + aapsLogger.error(LTag.DATABASE, "Error while saving bolus", it) }) } else { commandQueue.bolus(detailedBolusInfo, object : Callback() { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt index 7cebd826f0..6d3cf25ec3 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -21,7 +21,6 @@ import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.alertDialogs.OKDialog @@ -41,7 +40,6 @@ class TempTargetDialog : DialogFragmentWithDate() { @Inject lateinit var defaultValueHelper: DefaultValueHelper @Inject lateinit var uel: UserEntryLogger @Inject lateinit var repository: AppRepository - @Inject lateinit var nsUpload: NSUpload private lateinit var reasonList: List @@ -135,19 +133,19 @@ class TempTargetDialog : DialogFragmentWithDate() { binding.reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.eatingsoon))) } - R.id.activity -> { + R.id.activity -> { binding.temptarget.value = defaultValueHelper.determineActivityTT() binding.duration.value = defaultValueHelper.determineActivityTTDuration().toDouble() binding.reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.activity))) } - R.id.hypo -> { + R.id.hypo -> { binding.temptarget.value = defaultValueHelper.determineHypoTT() binding.duration.value = defaultValueHelper.determineHypoTTDuration().toDouble() binding.reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.hypo))) } - R.id.cancel -> { + R.id.cancel -> { binding.duration.value = 0.0 } } @@ -180,19 +178,19 @@ class TempTargetDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { val units = profileFunction.getUnits() - when(reason) { - resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.activity) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.CUSTOM.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + when (reason) { + resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.activity) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.CUSTOM.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged)) } if (target == 0.0 || duration == 0) { disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(eventTime)) .subscribe({ result -> - result.updated.forEach { nsUpload.updateTempTarget(it) } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it) + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) }) } else { disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( @@ -200,17 +198,17 @@ class TempTargetDialog : DialogFragmentWithDate() { duration = TimeUnit.MINUTES.toMillis(duration.toLong()), reason = when (reason) { resourceHelper.gs(R.string.eatingsoon) -> TemporaryTarget.Reason.EATING_SOON - resourceHelper.gs(R.string.activity) -> TemporaryTarget.Reason.ACTIVITY - resourceHelper.gs(R.string.hypo) -> TemporaryTarget.Reason.HYPOGLYCEMIA - else -> TemporaryTarget.Reason.CUSTOM + resourceHelper.gs(R.string.activity) -> TemporaryTarget.Reason.ACTIVITY + resourceHelper.gs(R.string.hypo) -> TemporaryTarget.Reason.HYPOGLYCEMIA + else -> TemporaryTarget.Reason.CUSTOM }, lowTarget = Profile.toMgdl(target, profileFunction.getUnits()), highTarget = Profile.toMgdl(target, profileFunction.getUnits()) )).subscribe({ result -> - result.inserted.forEach { nsUpload.uploadTempTarget(it) } - result.updated.forEach { nsUpload.updateTempTarget(it) } + result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it) + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt index b7e567a88c..95152325b1 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt @@ -158,7 +158,7 @@ class TreatmentDialog : DialogFragmentWithDate() { nsUpload.uploadBolusRecord(it, detailedBolusInfo.createTherapyEvent(), null) } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving bolus", it) + aapsLogger.error(LTag.DATABASE, "Error while saving bolus", it) }) disposable += repository.runTransactionForResult(detailedBolusInfo.insertCarbsTransaction()) .subscribe({ result -> @@ -167,7 +167,7 @@ class TreatmentDialog : DialogFragmentWithDate() { nsUpload.uploadCarbsRecord(it, detailedBolusInfo.createTherapyEvent()) } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving carbs", it) + aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it) }) } else { commandQueue.bolus(detailedBolusInfo, object : Callback() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt index 5e4d6e9864..19f7ba215d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt @@ -661,7 +661,7 @@ open class LoopPlugin @Inject constructor( )).subscribe({ result -> result.inserted.forEach { nsUpload.uploadEvent(it) } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving therapy event", it) + aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt index ceb0855819..6f8a9682f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt @@ -258,7 +258,7 @@ class FoodFragment : DaggerFragment() { // no create at the moment // else uploadQueue.removeID("dbAdd", food.timestamp.toString()) }, { - aapsLogger.error(LTag.BGSOURCE, "Error while invalidating food", it) + aapsLogger.error(LTag.DATABASE, "Error while invalidating food", it) }) }, null) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt index f0f78a8577..27d68d2c0b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt @@ -57,7 +57,7 @@ class FoodPlugin @Inject constructor( override fun doWork(): Result { val foods = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) ?: return Result.failure() - aapsLogger.debug(LTag.DATAFOOD, "Received Food Data: $foods") + aapsLogger.debug(LTag.DATABASE, "Received Food Data: $foods") var ret = Result.success() @@ -77,12 +77,12 @@ class FoodPlugin @Inject constructor( repository.runTransactionForResult(SyncFoodTransaction(delFood)) .doOnError { - aapsLogger.error(LTag.DATAFOOD, "Error while removing food", it) + aapsLogger.error(LTag.DATABASE, "Error while removing food", it) ret = Result.failure() } .blockingGet() .also { - it.invalidated.forEach { f -> aapsLogger.debug(LTag.DATAFOOD, "Invalidated food ${f.interfaceIDs.nightscoutId}") } + it.invalidated.forEach { f -> aapsLogger.debug(LTag.DATABASE, "Invalidated food ${f.interfaceIDs.nightscoutId}") } } } @@ -91,17 +91,17 @@ class FoodPlugin @Inject constructor( if (food != null) { repository.runTransactionForResult(SyncFoodTransaction(food)) .doOnError { - aapsLogger.error(LTag.DATAFOOD, "Error while adding/updating food", it) + aapsLogger.error(LTag.DATABASE, "Error while adding/updating food", it) ret = Result.failure() } .blockingGet() .also { result -> - result.inserted.forEach { aapsLogger.debug(LTag.DATAFOOD, "Inserted food $it") } - result.updated.forEach { aapsLogger.debug(LTag.DATAFOOD, "Updated food $it") } - result.invalidated.forEach { aapsLogger.debug(LTag.DATAFOOD, "Invalidated food $it") } + result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted food $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated food $it") } + result.invalidated.forEach { aapsLogger.debug(LTag.DATABASE, "Invalidated food $it") } } } else { - aapsLogger.error(LTag.DATAFOOD, "Error parsing food", jsonFood.toString()) + aapsLogger.error(LTag.DATABASE, "Error parsing food", jsonFood.toString()) ret = Result.failure() } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/DataSyncSelectorImplementation.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/DataSyncSelectorImplementation.kt new file mode 100644 index 0000000000..139dc30f10 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/DataSyncSelectorImplementation.kt @@ -0,0 +1,73 @@ +package info.nightscout.androidaps.plugins.general.nsclient + +import androidx.work.ListenableWorker +import info.nightscout.androidaps.R +import info.nightscout.androidaps.database.AppRepository +import info.nightscout.androidaps.database.entities.TemporaryTarget +import info.nightscout.androidaps.database.transactions.UpdateTemporaryTargetTransaction +import info.nightscout.androidaps.db.DbRequest +import info.nightscout.androidaps.interfaces.DataSyncSelector +import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.extensions.toJson +import info.nightscout.androidaps.utils.sharedPreferences.SP +import javax.inject.Inject + +class DataSyncSelectorImplementation @Inject constructor( + private val sp: SP, + private val aapsLogger: AAPSLogger, + private val dateUtil: DateUtil, + private val profileFunction: ProfileFunction, + private val appRepository: AppRepository +) : DataSyncSelector { + + /* + val updateTempTargetNsId = Runnable { + interfaceIDs.nightscoutId = nsId + repository.runTransactionForResult(UpdateTemporaryTargetTransaction(this)) + .doOnError { + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) + ret = ListenableWorker.Result.failure() + } + .blockingGet() + } + */ + + override fun resetToNextFullSync() { + sp.remove(R.string.key_ns_temporary_target_last_sync) + } + + override fun confirmTempTargetsTimestamp(lastSynced: Long) { + sp.putLong(R.string.key_ns_temporary_target_last_sync, lastSynced) + } + + override fun changedTempTargets(): List { + val startTime = sp.getLong(R.string.key_ns_temporary_target_last_sync, 0) + return appRepository.getAllChangedTemporaryTargetsFromTime(startTime).blockingGet().also { + aapsLogger.debug(LTag.NSCLIENT, "Loading TT data for sync from ${dateUtil.dateAndTimeAndSecondsString(startTime)}. Records ${it.size}") + } + } + + override fun changedTempTargetsCompat(): List { + val changedTT = changedTempTargets() + val prepared = mutableListOf() + changedTT.forEach { tt -> + when { + // removed and not uploaded yet = ignore + !tt.isValid && tt.interfaceIDs.nightscoutId == null -> Unit + // removed and already uploaded = send for removal + !tt.isValid && tt.interfaceIDs.nightscoutId != null -> + prepared.add(DbRequest("dbRemove", "treatments", tt.interfaceIDs.nightscoutId, dateUtil._now())) + // existing without nsId = create new + tt.isValid && tt.interfaceIDs.nightscoutId == null -> + prepared.add(DbRequest("dbAdd", "treatments", tt.toJson(profileFunction.getUnits()), tt.timestamp)) + // existing with nsId = update + tt.isValid && tt.interfaceIDs.nightscoutId != null -> + prepared.add(DbRequest("dbUpdate", "treatments", tt.interfaceIDs.nightscoutId, tt.toJson(profileFunction.getUnits()), tt.timestamp)) + } + } + return prepared + } +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt index 868993ddc8..c3e96e33c4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt @@ -64,7 +64,7 @@ class NSClientAddUpdateWorker( val carbs = JsonHelper.safeGetDouble(json, "carbs") val eventType = JsonHelper.safeGetString(json, "eventType") if (eventType == null) { - aapsLogger.debug(LTag.DATASERVICE, "Wrong treatment. Ignoring : $json") + aapsLogger.debug(LTag.NSCLIENT, "Wrong treatment. Ignoring : $json") continue } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/acks/NSAddAck.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/acks/NSAddAck.java index dbd9151938..2faa7ce261 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/acks/NSAddAck.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/acks/NSAddAck.java @@ -38,6 +38,7 @@ public class NSAddAck extends Event implements Ack { if (response.has("NSCLIENT_ID")) { nsClientID = response.getString("NSCLIENT_ID"); } + aapsLogger.debug(LTag.NSCLIENT, "DBACCESS YYYYY " + this.toString() + " " + response.toString()); } rxBus.send(this); return; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java index 809bbae38b..a680e58360 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java @@ -36,6 +36,7 @@ import info.nightscout.androidaps.db.DbRequest; import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventConfigBuilderChange; import info.nightscout.androidaps.events.EventPreferenceChange; +import info.nightscout.androidaps.interfaces.DataSyncSelector; import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.UploadQueueInterface; @@ -78,6 +79,7 @@ import io.reactivex.disposables.CompositeDisposable; import io.socket.client.IO; import io.socket.client.Socket; import io.socket.emitter.Emitter; +import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType; public class NSClientService extends DaggerService { @Inject HasAndroidInjector injector; @@ -96,6 +98,7 @@ public class NSClientService extends DaggerService { @Inject DateUtil dateUtil; @Inject UploadQueueInterface uploadQueue; @Inject DataWorker dataWorker; + @Inject DataSyncSelector dataSyncSelector; private final CompositeDisposable disposable = new CompositeDisposable(); @@ -738,6 +741,19 @@ public class NSClientService extends DaggerService { } } + public void dbAdd(DbRequest dbr, NSAddAck ack, JvmType.Object originalData) { + try { + if (!isConnected || !hasWriteAuth) return; + JSONObject message = new JSONObject(); + message.put("collection", dbr.collection); + message.put("data", new JSONObject(dbr.data)); + mSocket.emit("dbAdd", message, ack); + rxBus.send(new EventNSClientNewLog("DBADD " + dbr.collection, "Sent " + dbr.nsClientID)); + } catch (JSONException e) { + aapsLogger.error("Unhandled exception", e); + } + } + public void sendAlarmAck(AlarmAck alarmAck) { if (!isConnected || !hasWriteAuth) return; mSocket.emit("ack", alarmAck.level, alarmAck.group, alarmAck.silenceTime); @@ -761,6 +777,12 @@ public class NSClientService extends DaggerService { rxBus.send(new EventNSClientNewLog("QUEUE", "Resend started: " + reason)); + List ttData = dataSyncSelector.changedTempTargetsCompat(); + for (DbRequest dbr : ttData) { + uploadQueue.add(dbr); + dataSyncSelector.confirmTempTargetsTimestamp(Long.parseLong(dbr.nsClientID)); + } + CloseableIterator iterator; int maxcount = 30; try { @@ -768,19 +790,7 @@ public class NSClientService extends DaggerService { try { while (iterator.hasNext() && maxcount > 0) { DbRequest dbr = iterator.next(); - if (dbr.action.equals("dbAdd")) { - NSAddAck addAck = new NSAddAck(aapsLogger, rxBus); - dbAdd(dbr, addAck); - } else if (dbr.action.equals("dbRemove")) { - NSUpdateAck removeAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger, rxBus); - dbRemove(dbr, removeAck); - } else if (dbr.action.equals("dbUpdate")) { - NSUpdateAck updateAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger, rxBus); - dbUpdate(dbr, updateAck); - } else if (dbr.action.equals("dbUpdateUnset")) { - NSUpdateAck updateUnsetAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger, rxBus); - dbUpdateUnset(dbr, updateUnsetAck); - } + processDbRequest(dbr); maxcount--; } } finally { @@ -794,6 +804,22 @@ public class NSClientService extends DaggerService { }); } + private void processDbRequest(DbRequest dbr) { + if (dbr.action.equals("dbAdd")) { + NSAddAck addAck = new NSAddAck(aapsLogger, rxBus); + dbAdd(dbr, addAck); + } else if (dbr.action.equals("dbRemove")) { + NSUpdateAck removeAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger, rxBus); + dbRemove(dbr, removeAck); + } else if (dbr.action.equals("dbUpdate")) { + NSUpdateAck updateAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger, rxBus); + dbUpdate(dbr, updateAck); + } else if (dbr.action.equals("dbUpdateUnset")) { + NSUpdateAck updateUnsetAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger, rxBus); + dbUpdateUnset(dbr, updateUnsetAck); + } + } + public void restart() { destroy(); initialize(); @@ -838,33 +864,7 @@ public class NSClientService extends DaggerService { } } - public void handleNewTreatment(JSONArray treatments, boolean isDelta) { - List splitted = splitArray(treatments); - for (JSONArray part : splitted) { - Bundle bundle = new Bundle(); - bundle.putString("treatments", part.toString()); - bundle.putBoolean("delta", isDelta); - Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT); - intent.putExtras(bundle); - intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - LocalBroadcastManager.getInstance(this).sendBroadcast(intent); - } - - if (sp.getBoolean(R.string.key_nsclient_localbroadcasts, false)) { - splitted = splitArray(treatments); - for (JSONArray part : splitted) { - Bundle bundle = new Bundle(); - bundle.putString("treatments", part.toString()); - bundle.putBoolean("delta", isDelta); - Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT); - intent.putExtras(bundle); - intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - this.getApplicationContext().sendBroadcast(intent); - } - } - } - - public List splitArray(JSONArray array) { + public List splitArray(JSONArray array) { List ret = new ArrayList<>(); try { int size = array.length(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index 49420b2c8f..981141cd83 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -78,7 +78,6 @@ class SmsCommunicatorPlugin @Inject constructor( private val config: Config, private val dateUtil: DateUtil, private val uel: UserEntryLogger, - private val nsUpload: NSUpload, private val glucoseStatusProvider: GlucoseStatusProvider, private val repository: AppRepository ) : PluginBase(PluginDescription() @@ -826,10 +825,10 @@ class SmsCommunicatorPlugin @Inject constructor( lowTarget = Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()), highTarget = Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()) )).subscribe({ result -> - result.inserted.forEach { nsUpload.uploadTempTarget(it) } - result.updated.forEach { nsUpload.updateTempTarget(it) } + result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it) + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) }) val tt = if (currentProfile.units == Constants.MMOL) { DecimalFormatter.to1Decimal(eatingSoonTT) @@ -960,10 +959,10 @@ class SmsCommunicatorPlugin @Inject constructor( lowTarget = Profile.toMgdl(tt, profileFunction.getUnits()), highTarget = Profile.toMgdl(tt, profileFunction.getUnits()) )).subscribe({ result -> - result.inserted.forEach { nsUpload.uploadTempTarget(it) } - result.updated.forEach { nsUpload.updateTempTarget(it) } + result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it) + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) }) val ttString = if (units == Constants.MMOL) DecimalFormatter.to1Decimal(tt) else DecimalFormatter.to0Decimal(tt) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_set), ttString, ttDuration) @@ -980,9 +979,9 @@ class SmsCommunicatorPlugin @Inject constructor( override fun run() { disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(dateUtil._now())) .subscribe({ result -> - result.updated.forEach { nsUpload.updateTempTarget(it) } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it) + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) }) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_canceled)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt index e6d7b0d793..07429c4fcc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt @@ -22,6 +22,7 @@ import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAnd import info.nightscout.androidaps.db.TDD import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker @@ -573,17 +574,17 @@ class ActionStringHandler @Inject constructor( lowTarget = Profile.toMgdl(low, profileFunction.getUnits()), highTarget = Profile.toMgdl(high, profileFunction.getUnits()) )).subscribe({ result -> - result.inserted.forEach { nsUpload.uploadTempTarget(it) } - result.updated.forEach { nsUpload.updateTempTarget(it) } + result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } }, { - aapsLogger.error("Error while saving temporary target", it) + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) }) else disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(System.currentTimeMillis())) .subscribe({ result -> - result.updated.forEach { nsUpload.updateTempTarget(it) } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } }, { - aapsLogger.error("Error while saving temporary target", it) + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt index f585fbfff5..86c4460c00 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt @@ -141,14 +141,14 @@ class EversensePlugin @Inject constructor( enteredBy = "AndroidAPS-Eversense" )) .doOnError { - aapsLogger.error(LTag.BGSOURCE, "Error while saving therapy event", it) + aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) ret = Result.failure() } .blockingGet() .also { result -> result.inserted.forEach { nsUpload.uploadEvent(it) - aapsLogger.debug(LTag.BGSOURCE, "Inserted bg $it") + aapsLogger.debug(LTag.DATABASE, "Inserted bg $it") } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt index aa776557ae..03e1782660 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt @@ -112,11 +112,11 @@ class RandomBgPlugin @Inject constructor( xDripBroadcast(it) if (sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) nsUpload.uploadBg(it, GlucoseValue.SourceSensor.RANDOM.text) - aapsLogger.debug(LTag.BGSOURCE, "Inserted bg $it") + aapsLogger.debug(LTag.DATABASE, "Inserted bg $it") } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving values from Random plugin", it) + aapsLogger.error(LTag.DATABASE, "Error while saving values from Random plugin", it) }) - aapsLogger.debug(LTag.BGSOURCE, "Generated BG: $bgMgdl ${Date()}") + aapsLogger.debug(LTag.DATABASE, "Generated BG: $bgMgdl ${Date()}") } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt index 3862e9f6d5..5d48cb6845 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt @@ -87,7 +87,7 @@ class XdripPlugin @Inject constructor( ) repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .doOnError { - aapsLogger.error(LTag.BGSOURCE, "Error while saving values from Eversense App", it) + aapsLogger.error(LTag.DATABASE, "Error while saving values from Eversense App", it) ret = Result.failure() } .blockingGet() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusCarbsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusCarbsFragment.kt index 0d6ae81abb..ad98524b31 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusCarbsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusCarbsFragment.kt @@ -125,7 +125,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeByMongoId("dbAdd", bolus.timestamp.toString()) }, { - aapsLogger.error(LTag.DATATREATMENTS, "Error while invalidating bolus", it) + aapsLogger.error(LTag.DATABASE, "Error while invalidating bolus", it) }) } } @@ -140,7 +140,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeByMongoId("dbAdd", carb.timestamp.toString()) }, { - aapsLogger.error(LTag.DATATREATMENTS, "Error while invalidating carbs", it) + aapsLogger.error(LTag.DATABASE, "Error while invalidating carbs", it) }) } } @@ -155,7 +155,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeByMongoId("dbAdd", bolusCalc.timestamp.toString()) }, { - aapsLogger.error(LTag.DATATREATMENTS, "Error while invalidating carbs", it) + aapsLogger.error(LTag.DATABASE, "Error while invalidating carbs", it) }) } } @@ -355,7 +355,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeByMongoId("dbAdd", bolus.timestamp.toString()) }, { - aapsLogger.error(LTag.DATATREATMENTS, "Error while invalidating bolus", it) + aapsLogger.error(LTag.DATABASE, "Error while invalidating bolus", it) }) }) } @@ -379,7 +379,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeByMongoId("dbAdd", carb.timestamp.toString()) }, { - aapsLogger.error(LTag.DATATREATMENTS, "Error while invalidating carbs", it) + aapsLogger.error(LTag.DATABASE, "Error while invalidating carbs", it) }) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt index 8cb304ad0d..67bb408722 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt @@ -105,7 +105,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { uploadQueue.removeByMongoId("dbAdd", event.timestamp.toString()) } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while invalidating therapy event", it) + aapsLogger.error(LTag.DATABASE, "Error while invalidating therapy event", it) }) }, null) } @@ -204,7 +204,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeByMongoId("dbAdd", therapyEvent.timestamp.toString()) }, { - aapsLogger.error(LTag.BGSOURCE, "Error while invalidating therapy event", it) + aapsLogger.error(LTag.DATABASE, "Error while invalidating therapy event", it) }) }, null) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt index 74fa9c95db..276043e30f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt @@ -14,7 +14,9 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.ValueWrapper import info.nightscout.androidaps.database.entities.TemporaryTarget -import info.nightscout.androidaps.database.entities.UserEntry.* +import info.nightscout.androidaps.database.entities.UserEntry.Action +import info.nightscout.androidaps.database.entities.UserEntry.Units +import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit import info.nightscout.androidaps.database.interfaces.end import info.nightscout.androidaps.database.transactions.InvalidateTemporaryTargetTransaction import info.nightscout.androidaps.databinding.TreatmentsTemptargetFragmentBinding @@ -26,7 +28,6 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart import info.nightscout.androidaps.plugins.treatments.events.EventTreatmentUpdateGui import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsTempTargetFragment.RecyclerViewAdapter.TempTargetsViewHolder @@ -57,7 +58,6 @@ class TreatmentsTempTargetFragment : DaggerFragment() { @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var resourceHelper: ResourceHelper - @Inject lateinit var nsUpload: NSUpload @Inject lateinit var uploadQueue: UploadQueueInterface @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var translator: Translator @@ -173,9 +173,9 @@ class TreatmentsTempTargetFragment : DaggerFragment() { holder.binding.reason.text = translator.translate(tempTarget.reason.text) holder.binding.date.setTextColor( when { - tempTarget.id == currentlyActiveTarget?.id -> resourceHelper.gc(R.color.colorActive) - tempTarget.timestamp > DateUtil.now() -> resourceHelper.gc(R.color.colorScheduled) - else -> holder.binding.reasonColon.currentTextColor + tempTarget.id == currentlyActiveTarget?.id -> resourceHelper.gc(R.color.colorActive) + tempTarget.timestamp > DateUtil.now() -> resourceHelper.gc(R.color.colorScheduled) + else -> holder.binding.reasonColon.currentTextColor }) holder.binding.remove.tag = tempTarget } @@ -198,13 +198,9 @@ class TreatmentsTempTargetFragment : DaggerFragment() { { _: DialogInterface?, _: Int -> uel.log(Action.TT_REMOVED, ValueWithUnit(tempTarget.timestamp, Units.Timestamp), ValueWithUnit(tempTarget.reason.text, Units.TherapyEvent), ValueWithUnit(tempTarget.lowTarget, Units.Mg_Dl), ValueWithUnit(tempTarget.highTarget, Units.Mg_Dl, tempTarget.lowTarget != tempTarget.highTarget), ValueWithUnit(tempTarget.duration.toInt(), Units.M)) disposable += repository.runTransactionForResult(InvalidateTemporaryTargetTransaction(tempTarget.id)) - .subscribe({ - val id = tempTarget.interfaceIDs.nightscoutId - if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) - else uploadQueue.removeByMongoId("dbAdd", tempTarget.timestamp.toString()) - }, { - aapsLogger.error(LTag.BGSOURCE, "Error while invalidating temporary target", it) - }) + .subscribe( + { aapsLogger.debug(LTag.DATABASE, "Removed temp target $tempTarget") }, + { aapsLogger.error(LTag.DATABASE, "Error while invalidating temporary target", it) }) }, null) } } diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt index e70b15a458..47060adacc 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt @@ -212,7 +212,7 @@ open class CommandQueue @Inject constructor( nsUpload.uploadCarbsRecord(it, detailedBolusInfo.createTherapyEvent()) } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving carbs", it) + aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it) }) // Do not process carbs anymore detailedBolusInfo.carbs = 0.0 diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.kt b/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.kt index 89a869837f..eb1c5f1837 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.kt +++ b/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.kt @@ -26,7 +26,7 @@ open class DataReceiver : DaggerBroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { super.onReceive(context, intent) val bundle = intent.extras ?: return - aapsLogger.debug(LTag.DATASERVICE, "onReceive ${intent.action} ${BundleLogger.log(bundle)}") + aapsLogger.debug(LTag.DATABASE, "onReceive ${intent.action} ${BundleLogger.log(bundle)}") when (intent.action) { diff --git a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt index db404d9235..2fb6497912 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt @@ -431,7 +431,7 @@ class BolusWizard @Inject constructor( nsUpload.uploadBolusCalc(this) } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving meal link", it) + aapsLogger.error(LTag.DATABASE, "Error while saving meal link", it) }) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2fc3812925..baa74b6dc1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -33,6 +33,7 @@ protection absorption_category_settings insulin_oref_peak_settings + ns_temporary_target_last_sync Treatments safety Max allowed bolus [U] @@ -1128,5 +1129,4 @@ Profile carbs ratio value - diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt index 7bebe4ac6c..bb81292848 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt @@ -19,7 +19,6 @@ import info.nightscout.androidaps.plugins.general.automation.elements.InputTempT import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTempTarget -import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.JsonHelper @@ -37,7 +36,6 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var repository: AppRepository - @Inject lateinit var nsUpload: NSUpload @Inject lateinit var profileFunction: ProfileFunction private val disposable = CompositeDisposable() @@ -56,11 +54,11 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) { override fun doAction(callback: Callback) { disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(tt())) .subscribe({ result -> - result.inserted.forEach { nsUpload.uploadTempTarget(it) } - result.updated.forEach { nsUpload.updateTempTarget(it) } + result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it) + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) callback.result(PumpEnactResult(injector).success(false).comment(R.string.error))?.run() }) } diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt index e566c6f6cf..893df3aa95 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt @@ -5,9 +5,7 @@ import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction -import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -18,9 +16,7 @@ import javax.inject.Inject class ActionStopTempTarget(injector: HasAndroidInjector) : Action(injector) { @Inject lateinit var resourceHelper: ResourceHelper - @Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var repository: AppRepository - @Inject lateinit var nsUpload: NSUpload @Inject lateinit var dateUtil: DateUtil private val disposable = CompositeDisposable() @@ -30,11 +26,11 @@ class ActionStopTempTarget(injector: HasAndroidInjector) : Action(injector) { override fun icon(): Int = R.drawable.ic_stop_24dp override fun doAction(callback: Callback) { - disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(DateUtil.now())) + disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(dateUtil._now())) .subscribe({ result -> - result.updated.forEach { nsUpload.updateTempTarget(it) } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it) + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) }) callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() } diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/DataSyncSelector.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/DataSyncSelector.kt new file mode 100644 index 0000000000..9aa8918c7d --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/DataSyncSelector.kt @@ -0,0 +1,15 @@ +package info.nightscout.androidaps.interfaces + +import info.nightscout.androidaps.database.entities.TemporaryTarget +import info.nightscout.androidaps.db.DbRequest + +interface DataSyncSelector { + + fun resetToNextFullSync() + + fun confirmTempTargetsTimestamp(lastSynced: Long) + fun changedTempTargets() : List + + // Until NS v3 + fun changedTempTargetsCompat() : List +} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/logging/LTag.kt b/core/src/main/java/info/nightscout/androidaps/logging/LTag.kt index 3e67466663..02e8904f00 100644 --- a/core/src/main/java/info/nightscout/androidaps/logging/LTag.kt +++ b/core/src/main/java/info/nightscout/androidaps/logging/LTag.kt @@ -9,8 +9,6 @@ enum class LTag(val tag: String, val defaultValue : Boolean = true, val requires CONFIGBUILDER("CONFIGBUILDER"), CONSTRAINTS("CONSTRAINTS"), DATABASE("DATABASE"), - DATAFOOD("DATAFOOD", defaultValue = false), - DATASERVICE("DATASERVICE"), DATATREATMENTS("DATATREATMENTS"), EVENTS("EVENTS", defaultValue = false, requiresRestart = true), GLUCOSE("GLUCOSE", defaultValue = false), diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java b/core/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java index abf999bba1..43f83757e0 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java @@ -359,46 +359,6 @@ public class NSUpload { } } - public void uploadTempTarget(TemporaryTarget tempTarget) { - try { - JSONObject data = new JSONObject(); - data.put("eventType", TherapyEvent.Type.TEMPORARY_TARGET.getText()); - data.put("duration", T.msecs(tempTarget.getDuration()).mins()); - data.put(ISVALID, tempTarget.isValid()); - if (tempTarget.getLowTarget() > 0) { - data.put("reason", tempTarget.getReason().getText()); - data.put("targetBottom", Profile.fromMgdlToUnits(tempTarget.getLowTarget(), profileFunction.getUnits())); - data.put("targetTop", Profile.fromMgdlToUnits(tempTarget.getHighTarget(), profileFunction.getUnits())); - data.put("units", profileFunction.getUnits()); - } - data.put("created_at", DateUtil.toISOString(tempTarget.getTimestamp())); - data.put("enteredBy", "AndroidAPS"); - uploadCareportalEntryToNS(data, tempTarget.getTimestamp()); - } catch (JSONException e) { - aapsLogger.error("Unhandled exception", e); - } - } - - public void updateTempTarget(TemporaryTarget tempTarget) { - try { - JSONObject data = new JSONObject(); - data.put("eventType", TherapyEvent.Type.TEMPORARY_TARGET.getText()); - data.put("duration", T.msecs(tempTarget.getDuration()).mins()); - data.put(ISVALID, tempTarget.isValid()); - if (tempTarget.getLowTarget() > 0) { - data.put("reason", tempTarget.getReason().getText()); - data.put("targetBottom", Profile.fromMgdlToUnits(tempTarget.getLowTarget(), profileFunction.getUnits())); - data.put("targetTop", Profile.fromMgdlToUnits(tempTarget.getHighTarget(), profileFunction.getUnits())); - data.put("units", profileFunction.getUnits()); - } - data.put("created_at", DateUtil.toISOString(tempTarget.getTimestamp())); - data.put("enteredBy", "AndroidAPS"); - uploadQueue.add(new DbRequest("dbUpdate", "treatments", tempTarget.getInterfaceIDs().getNightscoutId(), data, tempTarget.getTimestamp())); - } catch (JSONException e) { - aapsLogger.error("Unhandled exception", e); - } - } - public void updateProfileSwitch(ProfileSwitch profileSwitch) { try { JSONObject data = getJson(profileSwitch); diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/TemporaryTargetExtension.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/TemporaryTargetExtension.kt index b763d71b9b..f8f7b3aa28 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/TemporaryTargetExtension.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/TemporaryTargetExtension.kt @@ -1,12 +1,20 @@ package info.nightscout.androidaps.utils.extensions +import androidx.work.ListenableWorker +import com.google.gson.Gson import info.nightscout.androidaps.Constants import info.nightscout.androidaps.core.R import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.entities.TemporaryTarget -import info.nightscout.androidaps.plugins.general.nsclient.NSUpload +import info.nightscout.androidaps.database.entities.TherapyEvent +import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction +import info.nightscout.androidaps.database.transactions.UpdateTemporaryTargetTransaction +import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.JsonHelper +import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.resources.ResourceHelper import org.json.JSONObject import java.util.concurrent.TimeUnit @@ -37,7 +45,7 @@ fun temporaryTargetFromNsIdForInvalidating(nsId: String): TemporaryTarget = .put("duration", -1) .put("reason", "fake") .put("_id", nsId) - .put(NSUpload.ISVALID, false) + .put("isValid", false) )!! fun temporaryTargetFromJson(jsonObject: JSONObject): TemporaryTarget? { @@ -53,7 +61,7 @@ fun temporaryTargetFromJson(jsonObject: JSONObject): TemporaryTarget? { // this string can be localized from NS, it will not work in this case CUSTOM will be used val reason = TemporaryTarget.Reason.fromString(reasonString) val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) ?: return null - val isValid = JsonHelper.safeGetBoolean(jsonObject, NSUpload.ISVALID, true) + val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true) if (duration > 0L) { // not ending event @@ -81,4 +89,18 @@ fun temporaryTargetFromJson(jsonObject: JSONObject): TemporaryTarget? { ) tt.interfaceIDs.nightscoutId = id return tt -} \ No newline at end of file +} + +fun TemporaryTarget.toJson(units: String): JSONObject = + JSONObject() + .put("eventType", TherapyEvent.Type.TEMPORARY_TARGET.text) + .put("duration", T.msecs(duration).mins()) + .put("isValid", isValid) + .put("created_at", DateUtil.toISOString(timestamp)) + .put("enteredBy", "AndroidAPS").also { + if (lowTarget > 0) it + .put("reason", reason.text) + .put("targetBottom", Profile.fromMgdlToUnits(lowTarget, units)) + .put("targetTop", Profile.fromMgdlToUnits(highTarget, units)) + .put("units", units) + } diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt index 65613641b5..2504953ce4 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt @@ -191,7 +191,7 @@ open class DanaRS_Packet_APS_History_Events( )).subscribe({ result -> result.inserted.forEach { nsUpload.uploadEvent(it) } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving therapy event", it) + aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) }) status = "REFILL " + dateUtil.timeString(datetime) } @@ -229,7 +229,7 @@ open class DanaRS_Packet_APS_History_Events( )).subscribe({ result -> result.inserted.forEach { nsUpload.uploadEvent(it) } }, { - aapsLogger.error(LTag.BGSOURCE, "Error while saving therapy event", it) + aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) }) status = "PRIMECANNULA " + dateUtil.timeString(datetime) } 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 0b16c6733d..b6b54bd8b8 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/AppRepository.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/AppRepository.kt @@ -93,6 +93,10 @@ open class AppRepository @Inject internal constructor( .map { if (!ascending) it.reversed() else it } .subscribeOn(Schedulers.io()) + fun getAllChangedTemporaryTargetsFromTime(timestamp: Long): Single> = + database.temporaryTargetDao.getAllChangedFromTime(timestamp) + .subscribeOn(Schedulers.io()) + fun getTemporaryTargetDataIncludingInvalidFromTime(timestamp: Long, ascending: Boolean): Single> = database.temporaryTargetDao.getTemporaryTargetDataIncludingInvalidFromTime(timestamp) .map { if (!ascending) it.reversed() else it } diff --git a/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt b/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt index 14324eda80..14364b25f0 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt @@ -21,9 +21,9 @@ open class DatabaseModule { internal fun provideAppDatabase(context: Context, @DbFileName fileName: String) = Room .databaseBuilder(context, AppDatabase::class.java, fileName) - .addMigrations(migration5to6) - .addMigrations(migration6to7) - .addMigrations(migration7to8) + // .addMigrations(migration5to6) + // .addMigrations(migration6to7) + // .addMigrations(migration7to8) .fallbackToDestructiveMigration() .build() diff --git a/database/src/main/java/info/nightscout/androidaps/database/daos/TemporaryTargetDao.kt b/database/src/main/java/info/nightscout/androidaps/database/daos/TemporaryTargetDao.kt index 7126b14aa9..f07bbda4d7 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/daos/TemporaryTargetDao.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/daos/TemporaryTargetDao.kt @@ -17,6 +17,9 @@ internal interface TemporaryTargetDao : TraceableDao { @Query("DELETE FROM $TABLE_TEMPORARY_TARGETS") override fun deleteAllEntries() + @Query("SELECT * FROM $TABLE_TEMPORARY_TARGETS WHERE dateCreated >= :timestamp AND referenceId IS NULL ORDER BY timestamp ASC") + fun getAllChangedFromTime(timestamp: Long): Single> + @Query("SELECT * FROM $TABLE_TEMPORARY_TARGETS WHERE nightscoutId = :nsId AND referenceId IS NULL") fun findByNSId(nsId: String): TemporaryTarget? diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateTemporaryTargetTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateTemporaryTargetTransaction.kt index 0a9f140c20..f07a57fce2 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateTemporaryTargetTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateTemporaryTargetTransaction.kt @@ -2,11 +2,7 @@ package info.nightscout.androidaps.database.transactions import info.nightscout.androidaps.database.entities.TemporaryTarget -/** - * Updates the TemporaryTarget - */ -class UpdateTemporaryTargetTransaction(private val temporaryTarget: TemporaryTarget) : Transaction() { - +class UpdateTemporaryTargetTransaction(val temporaryTarget: TemporaryTarget) : Transaction() { override fun run() { database.temporaryTargetDao.updateExistingEntry(temporaryTarget) }