Improve TBR logging
This commit is contained in:
parent
4a2342c292
commit
e68c127129
3 changed files with 9 additions and 7 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<TemporaryBasal>()
|
||||
val updated = mutableListOf<Pair<TemporaryBasal,TemporaryBasal>>()
|
||||
}
|
||||
}
|
|
@ -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<TemporaryBasal>()
|
||||
val updated = mutableListOf<Pair<TemporaryBasal, TemporaryBasal>>()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue