NSC: fix cutting records on ns sync

This commit is contained in:
Milos Kozak 2023-01-06 15:23:29 +01:00
parent c1c46939ba
commit 82fb85c9e0
4 changed files with 4 additions and 4 deletions

View file

@ -39,7 +39,7 @@ class SyncNsExtendedBolusTransaction(private val extendedBoluses: List<ExtendedB
// not known nsId // not known nsId
val running = database.extendedBolusDao.getExtendedBolusActiveAt(extendedBolus.timestamp).blockingGet() val running = database.extendedBolusDao.getExtendedBolusActiveAt(extendedBolus.timestamp).blockingGet()
if (running != null && abs(running.timestamp - extendedBolus.timestamp) < 1000 && running.interfaceIDs.nightscoutId == null) { // allow missing milliseconds if (running != null && abs(running.timestamp - extendedBolus.timestamp) < 1000) { // allow missing milliseconds
// the same record, update nsId only // the same record, update nsId only
running.interfaceIDs.nightscoutId = extendedBolus.interfaceIDs.nightscoutId running.interfaceIDs.nightscoutId = extendedBolus.interfaceIDs.nightscoutId
database.extendedBolusDao.updateExistingEntry(running) database.extendedBolusDao.updateExistingEntry(running)

View file

@ -38,7 +38,7 @@ class SyncNsOfflineEventTransaction(private val offlineEvents: List<OfflineEvent
// not known nsId // not known nsId
val running = database.offlineEventDao.getOfflineEventActiveAt(offlineEvent.timestamp).blockingGet() val running = database.offlineEventDao.getOfflineEventActiveAt(offlineEvent.timestamp).blockingGet()
if (running != null && abs(running.timestamp - offlineEvent.timestamp) < 1000 && running.interfaceIDs.nightscoutId == null) { // allow missing milliseconds if (running != null && abs(running.timestamp - offlineEvent.timestamp) < 1000) { // allow missing milliseconds
// the same record, update nsId only // the same record, update nsId only
running.interfaceIDs.nightscoutId = offlineEvent.interfaceIDs.nightscoutId running.interfaceIDs.nightscoutId = offlineEvent.interfaceIDs.nightscoutId
database.offlineEventDao.updateExistingEntry(running) database.offlineEventDao.updateExistingEntry(running)

View file

@ -38,7 +38,7 @@ class SyncNsTemporaryBasalTransaction(private val temporaryBasals: List<Temporar
// not known nsId // not known nsId
val running = database.temporaryBasalDao.getTemporaryBasalActiveAt(temporaryBasal.timestamp).blockingGet() val running = database.temporaryBasalDao.getTemporaryBasalActiveAt(temporaryBasal.timestamp).blockingGet()
if (running != null && abs(running.timestamp - temporaryBasal.timestamp) < 1000 && running.interfaceIDs.nightscoutId == null) { // allow missing milliseconds if (running != null && abs(running.timestamp - temporaryBasal.timestamp) < 1000) { // allow missing milliseconds
// the same record, update nsId only // the same record, update nsId only
running.interfaceIDs.nightscoutId = temporaryBasal.interfaceIDs.nightscoutId running.interfaceIDs.nightscoutId = temporaryBasal.interfaceIDs.nightscoutId
database.temporaryBasalDao.updateExistingEntry(running) database.temporaryBasalDao.updateExistingEntry(running)

View file

@ -38,7 +38,7 @@ class SyncNsTemporaryTargetTransaction(private val temporaryTargets: List<Tempor
// not known nsId // not known nsId
val running = database.temporaryTargetDao.getTemporaryTargetActiveAt(temporaryTarget.timestamp).blockingGet() val running = database.temporaryTargetDao.getTemporaryTargetActiveAt(temporaryTarget.timestamp).blockingGet()
if (running != null && abs(running.timestamp - temporaryTarget.timestamp) < 1000 && running.interfaceIDs.nightscoutId == null) { // allow missing milliseconds if (running != null && abs(running.timestamp - temporaryTarget.timestamp) < 1000) { // allow missing milliseconds
// the same record, update nsId only // the same record, update nsId only
running.interfaceIDs.nightscoutId = temporaryTarget.interfaceIDs.nightscoutId running.interfaceIDs.nightscoutId = temporaryTarget.interfaceIDs.nightscoutId
database.temporaryTargetDao.updateExistingEntry(running) database.temporaryTargetDao.updateExistingEntry(running)