fix DeviceStatus upload

This commit is contained in:
Milos Kozak 2021-04-18 18:31:21 +02:00
parent 3928b579a7
commit 430a871993
14 changed files with 42 additions and 42 deletions

View file

@ -78,7 +78,7 @@ class FoodPlugin @Inject constructor(
repository.runTransactionForResult(SyncNsFoodTransaction(delFood, true))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while removing food", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also {
@ -92,7 +92,7 @@ class FoodPlugin @Inject constructor(
repository.runTransactionForResult(SyncNsFoodTransaction(food, false))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while adding/updating food", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->

View file

@ -44,7 +44,7 @@ class NSClientAddAckWorker(
repository.runTransactionForResult(UpdateNsIdTemporaryTargetTransaction(pair.value))
.doOnError { error ->
aapsLogger.error(LTag.DATABASE, "Updated ns id of TemporaryTarget failed", error)
ret = Result.failure((workDataOf("Error" to error)))
ret = Result.failure((workDataOf("Error" to error.toString())))
}
.doOnSuccess {
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
@ -63,7 +63,7 @@ class NSClientAddAckWorker(
repository.runTransactionForResult(UpdateNsIdGlucoseValueTransaction(pair.value))
.doOnError { error ->
aapsLogger.error(LTag.DATABASE, "Updated ns id of GlucoseValue failed", error)
ret = Result.failure((workDataOf("Error" to error)))
ret = Result.failure((workDataOf("Error" to error.toString())))
}
.doOnSuccess {
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
@ -82,7 +82,7 @@ class NSClientAddAckWorker(
repository.runTransactionForResult(UpdateNsIdFoodTransaction(pair.value))
.doOnError { error ->
aapsLogger.error(LTag.DATABASE, "Updated ns id of Food failed", error)
ret = Result.failure((workDataOf("Error" to error)))
ret = Result.failure((workDataOf("Error" to error.toString())))
}
.doOnSuccess {
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
@ -101,7 +101,7 @@ class NSClientAddAckWorker(
repository.runTransactionForResult(UpdateNsIdTherapyEventTransaction(pair.value))
.doOnError { error ->
aapsLogger.error(LTag.DATABASE, "Updated ns id of TherapyEvent failed", error)
ret = Result.failure((workDataOf("Error" to error)))
ret = Result.failure((workDataOf("Error" to error.toString())))
}
.doOnSuccess {
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
@ -120,7 +120,7 @@ class NSClientAddAckWorker(
repository.runTransactionForResult(UpdateNsIdBolusTransaction(pair.value))
.doOnError { error ->
aapsLogger.error(LTag.DATABASE, "Updated ns id of Bolus failed", error)
ret = Result.failure((workDataOf("Error" to error)))
ret = Result.failure((workDataOf("Error" to error.toString())))
}
.doOnSuccess {
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
@ -139,7 +139,7 @@ class NSClientAddAckWorker(
repository.runTransactionForResult(UpdateNsIdCarbsTransaction(pair.value))
.doOnError { error ->
aapsLogger.error(LTag.DATABASE, "Updated ns id of Carbs failed", error)
ret = Result.failure((workDataOf("Error" to error)))
ret = Result.failure((workDataOf("Error" to error.toString())))
}
.doOnSuccess {
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
@ -158,7 +158,7 @@ class NSClientAddAckWorker(
repository.runTransactionForResult(UpdateNsIdBolusCalculatorResultTransaction(pair.value))
.doOnError { error ->
aapsLogger.error(LTag.DATABASE, "Updated ns id of BolusCalculatorResult failed", error)
ret = Result.failure((workDataOf("Error" to error)))
ret = Result.failure((workDataOf("Error" to error.toString())))
}
.doOnSuccess {
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
@ -177,7 +177,7 @@ class NSClientAddAckWorker(
repository.runTransactionForResult(UpdateNsIdTemporaryBasalTransaction(pair.value))
.doOnError { error ->
aapsLogger.error(LTag.DATABASE, "Updated ns id of TemporaryBasal failed", error)
ret = Result.failure((workDataOf("Error" to error)))
ret = Result.failure((workDataOf("Error" to error.toString())))
}
.doOnSuccess {
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
@ -196,7 +196,7 @@ class NSClientAddAckWorker(
repository.runTransactionForResult(UpdateNsIdExtendedBolusTransaction(pair.value))
.doOnError { error ->
aapsLogger.error(LTag.DATABASE, "Updated ns id of ExtendedBolus failed", error)
ret = Result.failure((workDataOf("Error" to error)))
ret = Result.failure((workDataOf("Error" to error.toString())))
}
.doOnSuccess {
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
@ -215,17 +215,17 @@ class NSClientAddAckWorker(
repository.runTransactionForResult(UpdateNsIdDeviceStatusTransaction(deviceStatus))
.doOnError { error ->
aapsLogger.error(LTag.DATABASE, "Updated ns id of DeviceStatus failed", error)
ret = Result.failure((workDataOf("Error" to error)))
ret = Result.failure((workDataOf("Error" to error.toString())))
}
.doOnSuccess {
ret = Result.success(workDataOf("ProcessedData" to deviceStatus))
ret = Result.success(workDataOf("ProcessedData" to deviceStatus.toString()))
aapsLogger.debug(LTag.DATABASE, "Updated ns id of DeviceStatus $deviceStatus")
dataSyncSelector.confirmLastDeviceStatusIdIfGreater(deviceStatus.id)
}
.blockingGet()
rxBus.send(EventNSClientNewLog("DBADD", "Acked DeviceStatus" + deviceStatus.interfaceIDs.nightscoutId))
// Send new if waiting
dataSyncSelector.processChangedBolusCalculatorResultsCompat()
dataSyncSelector.processChangedDeviceStatusesCompat()
}
}
return ret

View file

@ -79,7 +79,7 @@ class NSClientAddUpdateWorker(
repository.runTransactionForResult(SyncNsBolusTransaction(bolus, invalidateByNsOnly = false))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving bolus", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->
@ -108,7 +108,7 @@ class NSClientAddUpdateWorker(
repository.runTransactionForResult(SyncNsCarbsTransaction(carb, invalidateByNsOnly = false))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->
@ -146,7 +146,7 @@ class NSClientAddUpdateWorker(
repository.runTransactionForResult(SyncNsTemporaryTargetTransaction(temporaryTarget, invalidateByNsOnly = false))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->
@ -196,7 +196,7 @@ class NSClientAddUpdateWorker(
repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEvent, invalidateByNsOnly = false))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->
@ -231,7 +231,7 @@ class NSClientAddUpdateWorker(
repository.runTransactionForResult(SyncNsExtendedBolusTransaction(extendedBolus, invalidateByNsOnly = false))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving extended bolus", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->
@ -272,7 +272,7 @@ class NSClientAddUpdateWorker(
repository.runTransactionForResult(SyncNsTemporaryBasalTransaction(temporaryBasal, invalidateByNsOnly = false))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving temporary basal", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->

View file

@ -44,7 +44,7 @@ class NSClientMbgWorker(
repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEventFromNsMbg(nsMbg), false))
.doOnError {
aapsLogger.error("Error while saving therapy event", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also {

View file

@ -61,7 +61,7 @@ class NSClientRemoveWorker(
repository.runTransactionForResult(SyncNsTemporaryTargetTransaction(temporaryTarget, invalidateByNsOnly = true))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while invalidating temporary target", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->
@ -81,7 +81,7 @@ class NSClientRemoveWorker(
repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEvent, invalidateByNsOnly = true))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while invalidating therapy event", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->
@ -98,7 +98,7 @@ class NSClientRemoveWorker(
repository.runTransactionForResult(SyncNsBolusTransaction(bolus, invalidateByNsOnly = true))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while invalidating bolus", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->
@ -114,7 +114,7 @@ class NSClientRemoveWorker(
repository.runTransactionForResult(SyncNsCarbsTransaction(carbs, invalidateByNsOnly = true))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while invalidating carbs", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->
@ -130,7 +130,7 @@ class NSClientRemoveWorker(
repository.runTransactionForResult(SyncNsTemporaryBasalTransaction(temporaryBasal, invalidateByNsOnly = true))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while invalidating temporary basal", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->
@ -146,7 +146,7 @@ class NSClientRemoveWorker(
repository.runTransactionForResult(SyncNsExtendedBolusTransaction(extendedBolus, invalidateByNsOnly = true))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while invalidating extended bolus", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->

View file

@ -144,7 +144,7 @@ class DexcomPlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, calibrations, sensorStartTime))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Dexcom App", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->
@ -173,7 +173,7 @@ class DexcomPlugin @Inject constructor(
}
} catch (e: Exception) {
aapsLogger.error("Error while processing intent from Dexcom App", e)
ret = Result.failure(workDataOf("Error" to e))
ret = Result.failure(workDataOf("Error" to e.toString()))
}
return ret
}

View file

@ -112,7 +112,7 @@ class EversensePlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Eversense App", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { savedValues ->
@ -142,7 +142,7 @@ class EversensePlugin @Inject constructor(
))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->

View file

@ -70,7 +70,7 @@ class GlimpPlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Glimp App", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { savedValues ->

View file

@ -88,7 +88,7 @@ class MM640gPlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Eversense App", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { savedValues ->
@ -99,7 +99,7 @@ class MM640gPlugin @Inject constructor(
}
} catch (e: JSONException) {
aapsLogger.error("Exception: ", e)
ret = Result.failure(workDataOf("Error" to e))
ret = Result.failure(workDataOf("Error" to e.toString()))
}
}
}

View file

@ -142,7 +142,7 @@ class NSClientSourcePlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null, !nsClientSourcePlugin.isEnabled()))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from NSClient App", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { result ->
@ -159,7 +159,7 @@ class NSClientSourcePlugin @Inject constructor(
}
} catch (e: Exception) {
aapsLogger.error("Unhandled exception", e)
ret = Result.failure(workDataOf("Error" to e))
ret = Result.failure(workDataOf("Error" to e.toString()))
}
// Objectives 0
sp.putBoolean(R.string.key_ObjectivesbgIsAvailableInNS, true)

View file

@ -81,7 +81,7 @@ class PoctechPlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Poctech App", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { savedValues ->
@ -92,7 +92,7 @@ class PoctechPlugin @Inject constructor(
}
} catch (e: JSONException) {
aapsLogger.error("Exception: ", e)
ret = Result.failure(workDataOf("Error" to e))
ret = Result.failure(workDataOf("Error" to e.toString()))
}
return ret
}

View file

@ -72,7 +72,7 @@ class TomatoPlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Tomato App", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { savedValues ->

View file

@ -91,7 +91,7 @@ class XdripPlugin @Inject constructor(
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
.doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Xdrip", it)
ret = Result.failure(workDataOf("Error" to it))
ret = Result.failure(workDataOf("Error" to it.toString()))
}
.blockingGet()
.also { savedValues ->

View file

@ -32,10 +32,10 @@ internal interface DeviceStatusDao {
fun findByNSId(nsId: String): DeviceStatus?
// This query will be used with v3 to get all changed records
@Query("SELECT * FROM $TABLE_DEVICE_STATUS WHERE id > :id ORDER BY id ASC")
@Query("SELECT * FROM $TABLE_DEVICE_STATUS WHERE id > :id AND nightscoutId IS NULL ORDER BY id ASC")
fun getModifiedFrom(id: Long): Single<List<DeviceStatus>>
// for WS we need 1 record only
@Query("SELECT * FROM $TABLE_DEVICE_STATUS WHERE id > :id ORDER BY id ASC limit 1")
@Query("SELECT * FROM $TABLE_DEVICE_STATUS WHERE id > :id AND nightscoutId IS NULL ORDER BY id ASC limit 1")
fun getNextModifiedOrNewAfter(id: Long): Maybe<DeviceStatus>
}