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 1f51c797ac..9e4f9fb189 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 @@ -271,7 +271,7 @@ class PumpSyncImplementation @Inject constructor( .blockingGet() .also { result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted TemporaryBasal $it") } - result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated TemporaryBasal \n${it.first}\n${it.second}") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated TemporaryBasal ${it.first} New: ${it.second}") } return result.inserted.size > 0 } } @@ -283,7 +283,7 @@ class PumpSyncImplementation @Inject constructor( .blockingGet() .also { result -> result.updated.forEach { - aapsLogger.debug(LTag.DATABASE, "Updated TemporaryBasal $it") + aapsLogger.debug(LTag.DATABASE, "Updated TemporaryBasal ${it.first} New: ${it.second}") } return result.updated.size > 0 } @@ -331,7 +331,7 @@ class PumpSyncImplementation @Inject constructor( .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving TemporaryBasal", it) } .blockingGet() .also { result -> - result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated TemporaryBasal $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated TemporaryBasal ${it.first} New: ${it.second}") } return result.updated.size > 0 } } diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/SyncPumpCancelTemporaryBasalIfAnyTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/SyncPumpCancelTemporaryBasalIfAnyTransaction.kt index d7c3d528a0..c66ab184e5 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/SyncPumpCancelTemporaryBasalIfAnyTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/SyncPumpCancelTemporaryBasalIfAnyTransaction.kt @@ -15,17 +15,18 @@ class SyncPumpCancelTemporaryBasalIfAnyTransaction( return result val running = database.temporaryBasalDao.getTemporaryBasalActiveAt(timestamp).blockingGet() if (running != null && running.interfaceIDs.endId == null) { // do not allow overwrite if cut by end event + val old = running.copy() if (running.timestamp != timestamp) running.end = timestamp // prevent zero duration else running.duration = 1 running.interfaceIDs.endId = endPumpId database.temporaryBasalDao.updateExistingEntry(running) - result.updated.add(running) + result.updated.add(Pair(old, running)) } return result } class TransactionResult { - val updated = mutableListOf() + val updated = mutableListOf>() } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/SyncTemporaryBasalWithTempIdTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/SyncTemporaryBasalWithTempIdTransaction.kt index 81f061a0ff..93a2e86ef8 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/SyncTemporaryBasalWithTempIdTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/SyncTemporaryBasalWithTempIdTransaction.kt @@ -16,6 +16,7 @@ class SyncTemporaryBasalWithTempIdTransaction( val result = TransactionResult() val current = database.temporaryBasalDao.findByPumpTempIds(bolus.interfaceIDs.temporaryId!!, bolus.interfaceIDs.pumpType!!, bolus.interfaceIDs.pumpSerial!!) if (current != null) { + val old = current.copy() current.timestamp = bolus.timestamp current.rate = bolus.rate current.duration = bolus.duration @@ -23,13 +24,13 @@ class SyncTemporaryBasalWithTempIdTransaction( current.type = newType ?: current.type current.interfaceIDs.pumpId = bolus.interfaceIDs.pumpId database.temporaryBasalDao.updateExistingEntry(current) - result.updated.add(current) + result.updated.add(Pair(old, current)) } return result } class TransactionResult { - val updated = mutableListOf() + val updated = mutableListOf>() } } \ No newline at end of file