Better log TBR

This commit is contained in:
Milos Kozak 2022-04-29 19:07:36 +02:00
parent 3f1df34469
commit 2d653c67ef
2 changed files with 7 additions and 4 deletions

View file

@ -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 $it") }
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated ${it.first} TemporaryBasal ${it.second}") }
return result.inserted.size > 0
}
}

View file

@ -29,7 +29,7 @@ class SyncPumpTemporaryBasalTransaction(
existing.duration = temporaryBasal.duration
existing.type = type ?: existing.type
database.temporaryBasalDao.updateExistingEntry(existing)
result.updated.add(existing)
result.updated.add(Pair(Reason.EXISTING_ID, existing))
}
} else {
val running = database.temporaryBasalDao.getTemporaryBasalActiveAt(temporaryBasal.timestamp).blockingGet()
@ -37,7 +37,7 @@ class SyncPumpTemporaryBasalTransaction(
running.end = temporaryBasal.timestamp
running.interfaceIDs.endId = temporaryBasal.interfaceIDs.pumpId
database.temporaryBasalDao.updateExistingEntry(running)
result.updated.add(running)
result.updated.add(Pair(Reason.ACTIVE, running))
}
database.temporaryBasalDao.insertNewEntry(temporaryBasal)
result.inserted.add(temporaryBasal)
@ -45,9 +45,12 @@ class SyncPumpTemporaryBasalTransaction(
return result
}
enum class Reason {
EXISTING_ID, ACTIVE
}
class TransactionResult {
val inserted = mutableListOf<TemporaryBasal>()
val updated = mutableListOf<TemporaryBasal>()
val updated = mutableListOf<Pair<Reason,TemporaryBasal>>()
}
}