fix ending EB
This commit is contained in:
parent
6aaedefbed
commit
d0e9761e70
2 changed files with 5 additions and 1 deletions
|
@ -44,6 +44,8 @@ class SyncNsExtendedBolusTransaction(private val extendedBolus: ExtendedBolus) :
|
|||
result.updatedNsId.add(running)
|
||||
} else if (running != null) {
|
||||
// another running record. end current and insert new
|
||||
val pctRun = (extendedBolus.timestamp - running.timestamp) / running.duration.toDouble()
|
||||
running.amount *= pctRun
|
||||
running.end = extendedBolus.timestamp
|
||||
database.extendedBolusDao.updateExistingEntry(running)
|
||||
database.extendedBolusDao.insertNewEntry(extendedBolus)
|
||||
|
@ -59,6 +61,8 @@ class SyncNsExtendedBolusTransaction(private val extendedBolus: ExtendedBolus) :
|
|||
// ending event
|
||||
val running = database.extendedBolusDao.getExtendedBolusActiveAt(extendedBolus.timestamp).blockingGet()
|
||||
if (running != null) {
|
||||
val pctRun = (extendedBolus.timestamp - running.timestamp) / running.duration.toDouble()
|
||||
running.amount *= pctRun
|
||||
running.end = extendedBolus.timestamp
|
||||
database.extendedBolusDao.updateExistingEntry(running)
|
||||
result.ended.add(running)
|
||||
|
|
|
@ -30,7 +30,7 @@ class SyncPumpExtendedBolusTransaction(private val extendedBolus: ExtendedBolus)
|
|||
val running = database.extendedBolusDao.getExtendedBolusActiveAt(extendedBolus.timestamp, extendedBolus.interfaceIDs.pumpType!!, extendedBolus.interfaceIDs.pumpSerial!!).blockingGet()
|
||||
if (running != null) {
|
||||
val pctRun = (extendedBolus.timestamp - running.timestamp) / running.duration.toDouble()
|
||||
running.amount /= pctRun
|
||||
running.amount *= pctRun
|
||||
running.end = extendedBolus.timestamp
|
||||
running.interfaceIDs.endId = extendedBolus.interfaceIDs.pumpId
|
||||
database.extendedBolusDao.updateExistingEntry(running)
|
||||
|
|
Loading…
Reference in a new issue