fix NS sync issue

This commit is contained in:
Milos Kozak 2021-06-26 22:15:02 +02:00
parent 49776c8872
commit e08af1e7e4
12 changed files with 50 additions and 26 deletions

View file

@ -6,7 +6,9 @@ class UpdateNsIdBolusCalculatorResultTransaction(val bolusCalculatorResult: Bolu
override fun run() {
val current = database.bolusCalculatorResultDao.findById(bolusCalculatorResult.id)
if (current != null && current.interfaceIDs.nightscoutId != bolusCalculatorResult.interfaceIDs.nightscoutId)
database.bolusCalculatorResultDao.updateExistingEntry(bolusCalculatorResult)
if (current != null && current.interfaceIDs.nightscoutId != bolusCalculatorResult.interfaceIDs.nightscoutId) {
current.interfaceIDs.nightscoutId = bolusCalculatorResult.interfaceIDs.nightscoutId
database.bolusCalculatorResultDao.updateExistingEntry(current)
}
}
}

View file

@ -6,7 +6,9 @@ class UpdateNsIdBolusTransaction(val bolus: Bolus) : Transaction<Unit>() {
override fun run() {
val current = database.bolusDao.findById(bolus.id)
if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId)
database.bolusDao.updateExistingEntry(bolus)
if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId) {
current.interfaceIDs.nightscoutId = bolus.interfaceIDs.nightscoutId
database.bolusDao.updateExistingEntry(current)
}
}
}

View file

@ -6,7 +6,9 @@ class UpdateNsIdCarbsTransaction(val carbs: Carbs) : Transaction<Unit>() {
override fun run() {
val current = database.carbsDao.findById(carbs.id)
if (current != null && current.interfaceIDs.nightscoutId != carbs.interfaceIDs.nightscoutId)
database.carbsDao.updateExistingEntry(carbs)
if (current != null && current.interfaceIDs.nightscoutId != carbs.interfaceIDs.nightscoutId) {
current.interfaceIDs.nightscoutId = carbs.interfaceIDs.nightscoutId
database.carbsDao.updateExistingEntry(current)
}
}
}

View file

@ -6,7 +6,9 @@ class UpdateNsIdDeviceStatusTransaction(val deviceStatus: DeviceStatus) : Transa
override fun run() {
val current = database.deviceStatusDao.findById(deviceStatus.id)
if (current != null && current.interfaceIDs.nightscoutId != deviceStatus.interfaceIDs.nightscoutId)
database.deviceStatusDao.update(deviceStatus)
if (current != null && current.interfaceIDs.nightscoutId != deviceStatus.interfaceIDs.nightscoutId) {
current.interfaceIDs.nightscoutId = deviceStatus.interfaceIDs.nightscoutId
database.deviceStatusDao.update(current)
}
}
}

View file

@ -6,7 +6,9 @@ class UpdateNsIdExtendedBolusTransaction(val bolus: ExtendedBolus) : Transaction
override fun run() {
val current = database.extendedBolusDao.findById(bolus.id)
if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId)
database.extendedBolusDao.updateExistingEntry(bolus)
if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId) {
current.interfaceIDs.nightscoutId = bolus.interfaceIDs.nightscoutId
database.extendedBolusDao.updateExistingEntry(current)
}
}
}

View file

@ -6,7 +6,9 @@ class UpdateNsIdFoodTransaction(val food: Food) : Transaction<Unit>() {
override fun run() {
val current = database.foodDao.findById(food.id)
if (current != null && current.interfaceIDs.nightscoutId != food.interfaceIDs.nightscoutId)
database.foodDao.updateExistingEntry(food)
if (current != null && current.interfaceIDs.nightscoutId != food.interfaceIDs.nightscoutId) {
current.interfaceIDs.nightscoutId = food.interfaceIDs.nightscoutId
database.foodDao.updateExistingEntry(current)
}
}
}

View file

@ -6,7 +6,9 @@ class UpdateNsIdGlucoseValueTransaction(val glucoseValue: GlucoseValue) : Transa
override fun run() {
val current = database.glucoseValueDao.findById(glucoseValue.id)
if (current != null && current.interfaceIDs.nightscoutId != glucoseValue.interfaceIDs.nightscoutId)
database.glucoseValueDao.updateExistingEntry(glucoseValue)
if (current != null && current.interfaceIDs.nightscoutId != glucoseValue.interfaceIDs.nightscoutId) {
current.interfaceIDs.nightscoutId = glucoseValue.interfaceIDs.nightscoutId
database.glucoseValueDao.updateExistingEntry(current)
}
}
}

View file

@ -6,7 +6,9 @@ class UpdateNsIdOfflineEventTransaction(val offlineEvent: OfflineEvent) : Transa
override fun run() {
val current = database.offlineEventDao.findById(offlineEvent.id)
if (current != null && current.interfaceIDs.nightscoutId != offlineEvent.interfaceIDs.nightscoutId)
database.offlineEventDao.updateExistingEntry(offlineEvent)
if (current != null && current.interfaceIDs.nightscoutId != offlineEvent.interfaceIDs.nightscoutId) {
current.interfaceIDs.nightscoutId = offlineEvent.interfaceIDs.nightscoutId
database.offlineEventDao.updateExistingEntry(current)
}
}
}

View file

@ -6,7 +6,9 @@ class UpdateNsIdProfileSwitchTransaction(val profileSwitch: ProfileSwitch) : Tra
override fun run() {
val current = database.profileSwitchDao.findById(profileSwitch.id)
if (current != null && current.interfaceIDs.nightscoutId != profileSwitch.interfaceIDs.nightscoutId)
database.profileSwitchDao.updateExistingEntry(profileSwitch)
if (current != null && current.interfaceIDs.nightscoutId != profileSwitch.interfaceIDs.nightscoutId) {
current.interfaceIDs.nightscoutId = profileSwitch.interfaceIDs.nightscoutId
database.profileSwitchDao.updateExistingEntry(current)
}
}
}

View file

@ -2,11 +2,13 @@ package info.nightscout.androidaps.database.transactions
import info.nightscout.androidaps.database.entities.TemporaryBasal
class UpdateNsIdTemporaryBasalTransaction(val bolus: TemporaryBasal) : Transaction<Unit>() {
class UpdateNsIdTemporaryBasalTransaction(val temporaryBasal: TemporaryBasal) : Transaction<Unit>() {
override fun run() {
val current = database.temporaryBasalDao.findById(bolus.id)
if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId)
database.temporaryBasalDao.updateExistingEntry(bolus)
val current = database.temporaryBasalDao.findById(temporaryBasal.id)
if (current != null && current.interfaceIDs.nightscoutId != temporaryBasal.interfaceIDs.nightscoutId) {
current.interfaceIDs.nightscoutId = temporaryBasal.interfaceIDs.nightscoutId
database.temporaryBasalDao.updateExistingEntry(current)
}
}
}

View file

@ -6,7 +6,9 @@ class UpdateNsIdTemporaryTargetTransaction(val temporaryTarget: TemporaryTarget)
override fun run() {
val current = database.temporaryTargetDao.findById(temporaryTarget.id)
if (current != null && current.interfaceIDs.nightscoutId != temporaryTarget.interfaceIDs.nightscoutId)
database.temporaryTargetDao.updateExistingEntry(temporaryTarget)
if (current != null && current.interfaceIDs.nightscoutId != temporaryTarget.interfaceIDs.nightscoutId) {
current.interfaceIDs.nightscoutId = temporaryTarget.interfaceIDs.nightscoutId
database.temporaryTargetDao.updateExistingEntry(current)
}
}
}

View file

@ -6,7 +6,9 @@ class UpdateNsIdTherapyEventTransaction(val therapyEvent: TherapyEvent) : Transa
override fun run() {
val current = database.therapyEventDao.findById(therapyEvent.id)
if (current != null && current.interfaceIDs.nightscoutId != therapyEvent.interfaceIDs.nightscoutId)
database.therapyEventDao.updateExistingEntry(therapyEvent)
if (current != null && current.interfaceIDs.nightscoutId != therapyEvent.interfaceIDs.nightscoutId) {
current.interfaceIDs.nightscoutId = therapyEvent.interfaceIDs.nightscoutId
database.therapyEventDao.updateExistingEntry(current)
}
}
}