sync BolusCalculatorResult in full mode
This commit is contained in:
parent
67b4eaee70
commit
7ba4c19298
|
@ -85,14 +85,16 @@ class NSClientAddUpdateWorker(
|
|||
.blockingGet()
|
||||
.also { result ->
|
||||
result.inserted.forEach {
|
||||
uel.log(Action.BOLUS, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.BOLUS, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp),
|
||||
ValueWithUnit.Insulin(it.amount)
|
||||
)
|
||||
aapsLogger.debug(LTag.DATABASE, "Inserted bolus $it")
|
||||
}
|
||||
result.invalidated.forEach {
|
||||
uel.log(Action.BOLUS_REMOVED, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.BOLUS_REMOVED, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp),
|
||||
ValueWithUnit.Insulin(it.amount)
|
||||
)
|
||||
|
@ -119,21 +121,24 @@ class NSClientAddUpdateWorker(
|
|||
.blockingGet()
|
||||
.also { result ->
|
||||
result.inserted.forEach {
|
||||
uel.log(Action.CARBS, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.CARBS, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp),
|
||||
ValueWithUnit.Gram(it.amount.toInt())
|
||||
)
|
||||
aapsLogger.debug(LTag.DATABASE, "Inserted carbs $it")
|
||||
}
|
||||
result.invalidated.forEach {
|
||||
uel.log(Action.CARBS_REMOVED, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.CARBS_REMOVED, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp),
|
||||
ValueWithUnit.Gram(it.amount.toInt())
|
||||
)
|
||||
aapsLogger.debug(LTag.DATABASE, "Invalidated carbs $it")
|
||||
}
|
||||
result.updated.forEach {
|
||||
uel.log(Action.CARBS, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.CARBS, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp),
|
||||
ValueWithUnit.Gram(it.amount.toInt())
|
||||
)
|
||||
|
@ -169,7 +174,8 @@ class NSClientAddUpdateWorker(
|
|||
.blockingGet()
|
||||
.also { result ->
|
||||
result.inserted.forEach { tt ->
|
||||
uel.log(Action.TT, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.TT, Sources.NSClient,
|
||||
ValueWithUnit.TherapyEventTTReason(tt.reason),
|
||||
ValueWithUnit.fromGlucoseUnit(tt.lowTarget, Constants.MGDL),
|
||||
ValueWithUnit.fromGlucoseUnit(tt.highTarget, Constants.MGDL).takeIf { tt.lowTarget != tt.highTarget },
|
||||
|
@ -178,7 +184,8 @@ class NSClientAddUpdateWorker(
|
|||
aapsLogger.debug(LTag.DATABASE, "Inserted TemporaryTarget $tt")
|
||||
}
|
||||
result.invalidated.forEach { tt ->
|
||||
uel.log(Action.TT_REMOVED, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.TT_REMOVED, Sources.NSClient,
|
||||
ValueWithUnit.TherapyEventTTReason(tt.reason),
|
||||
ValueWithUnit.Mgdl(tt.lowTarget),
|
||||
ValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
|
||||
|
@ -187,7 +194,8 @@ class NSClientAddUpdateWorker(
|
|||
aapsLogger.debug(LTag.DATABASE, "Invalidated TemporaryTarget $tt")
|
||||
}
|
||||
result.ended.forEach { tt ->
|
||||
uel.log(Action.CANCEL_TT, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.CANCEL_TT, Sources.NSClient,
|
||||
ValueWithUnit.TherapyEventTTReason(tt.reason),
|
||||
ValueWithUnit.Mgdl(tt.lowTarget),
|
||||
ValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
|
||||
|
@ -215,13 +223,17 @@ class NSClientAddUpdateWorker(
|
|||
.blockingGet()
|
||||
.also { result ->
|
||||
result.inserted.forEach {
|
||||
uel.log(Action.PROFILE_SWITCH, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp))
|
||||
uel.log(
|
||||
Action.PROFILE_SWITCH, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp)
|
||||
)
|
||||
aapsLogger.debug(LTag.DATABASE, "Inserted EffectiveProfileSwitch $it")
|
||||
}
|
||||
result.invalidated.forEach {
|
||||
uel.log(Action.PROFILE_SWITCH_REMOVED, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp))
|
||||
uel.log(
|
||||
Action.PROFILE_SWITCH_REMOVED, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp)
|
||||
)
|
||||
aapsLogger.debug(LTag.DATABASE, "Invalidated EffectiveProfileSwitch $it")
|
||||
}
|
||||
result.updatedNsId.forEach {
|
||||
|
@ -231,7 +243,6 @@ class NSClientAddUpdateWorker(
|
|||
} ?: aapsLogger.error("Error parsing EffectiveProfileSwitch json $json")
|
||||
}
|
||||
eventType == TherapyEvent.Type.BOLUS_WIZARD.text ->
|
||||
if (config.NSCLIENT) {
|
||||
bolusCalculatorResultFromJson(json)?.let { bolusCalculatorResult ->
|
||||
repository.runTransactionForResult(SyncNsBolusCalculatorResultTransaction(bolusCalculatorResult))
|
||||
.doOnError {
|
||||
|
@ -241,13 +252,15 @@ class NSClientAddUpdateWorker(
|
|||
.blockingGet()
|
||||
.also { result ->
|
||||
result.inserted.forEach {
|
||||
uel.log(Action.BOLUS_CALCULATOR_RESULT, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.BOLUS_CALCULATOR_RESULT, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp),
|
||||
)
|
||||
aapsLogger.debug(LTag.DATABASE, "Inserted BolusCalculatorResult $it")
|
||||
}
|
||||
result.invalidated.forEach {
|
||||
uel.log(Action.BOLUS_CALCULATOR_RESULT_REMOVED, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.BOLUS_CALCULATOR_RESULT_REMOVED, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp),
|
||||
)
|
||||
aapsLogger.debug(LTag.DATABASE, "Invalidated BolusCalculatorResult $it")
|
||||
|
@ -257,7 +270,6 @@ class NSClientAddUpdateWorker(
|
|||
}
|
||||
}
|
||||
} ?: aapsLogger.error("Error parsing BolusCalculatorResult json $json")
|
||||
}
|
||||
eventType == TherapyEvent.Type.CANNULA_CHANGE.text ||
|
||||
eventType == TherapyEvent.Type.INSULIN_CHANGE.text ||
|
||||
eventType == TherapyEvent.Type.SENSOR_CHANGE.text ||
|
||||
|
@ -320,7 +332,8 @@ class NSClientAddUpdateWorker(
|
|||
.blockingGet()
|
||||
.also { result ->
|
||||
result.inserted.forEach {
|
||||
uel.log(Action.EXTENDED_BOLUS, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.EXTENDED_BOLUS, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp),
|
||||
ValueWithUnit.Insulin(it.amount),
|
||||
ValueWithUnit.UnitPerHour(it.rate),
|
||||
|
@ -329,7 +342,8 @@ class NSClientAddUpdateWorker(
|
|||
aapsLogger.debug(LTag.DATABASE, "Inserted ExtendedBolus $it")
|
||||
}
|
||||
result.invalidated.forEach {
|
||||
uel.log(Action.EXTENDED_BOLUS_REMOVED, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.EXTENDED_BOLUS_REMOVED, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp),
|
||||
ValueWithUnit.Insulin(it.amount),
|
||||
ValueWithUnit.UnitPerHour(it.rate),
|
||||
|
@ -338,7 +352,8 @@ class NSClientAddUpdateWorker(
|
|||
aapsLogger.debug(LTag.DATABASE, "Invalidated ExtendedBolus $it")
|
||||
}
|
||||
result.ended.forEach {
|
||||
uel.log(Action.CANCEL_EXTENDED_BOLUS, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.CANCEL_EXTENDED_BOLUS, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp),
|
||||
ValueWithUnit.Insulin(it.amount),
|
||||
ValueWithUnit.UnitPerHour(it.rate),
|
||||
|
@ -366,7 +381,8 @@ class NSClientAddUpdateWorker(
|
|||
.blockingGet()
|
||||
.also { result ->
|
||||
result.inserted.forEach {
|
||||
uel.log(Action.TEMP_BASAL, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.TEMP_BASAL, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp),
|
||||
if (it.isAbsolute) ValueWithUnit.UnitPerHour(it.rate) else ValueWithUnit.Percent(it.rate.toInt()),
|
||||
ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt())
|
||||
|
@ -374,7 +390,8 @@ class NSClientAddUpdateWorker(
|
|||
aapsLogger.debug(LTag.DATABASE, "Inserted TemporaryBasal $it")
|
||||
}
|
||||
result.invalidated.forEach {
|
||||
uel.log(Action.TEMP_BASAL_REMOVED, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.TEMP_BASAL_REMOVED, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp),
|
||||
if (it.isAbsolute) ValueWithUnit.UnitPerHour(it.rate) else ValueWithUnit.Percent(it.rate.toInt()),
|
||||
ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt())
|
||||
|
@ -382,7 +399,8 @@ class NSClientAddUpdateWorker(
|
|||
aapsLogger.debug(LTag.DATABASE, "Invalidated TemporaryBasal $it")
|
||||
}
|
||||
result.ended.forEach {
|
||||
uel.log(Action.CANCEL_TEMP_BASAL, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.CANCEL_TEMP_BASAL, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp),
|
||||
if (it.isAbsolute) ValueWithUnit.UnitPerHour(it.rate) else ValueWithUnit.Percent(it.rate.toInt()),
|
||||
ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt())
|
||||
|
@ -409,13 +427,17 @@ class NSClientAddUpdateWorker(
|
|||
.blockingGet()
|
||||
.also { result ->
|
||||
result.inserted.forEach {
|
||||
uel.log(Action.PROFILE_SWITCH, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp))
|
||||
uel.log(
|
||||
Action.PROFILE_SWITCH, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp)
|
||||
)
|
||||
aapsLogger.debug(LTag.DATABASE, "Inserted ProfileSwitch $it")
|
||||
}
|
||||
result.invalidated.forEach {
|
||||
uel.log(Action.PROFILE_SWITCH_REMOVED, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp))
|
||||
uel.log(
|
||||
Action.PROFILE_SWITCH_REMOVED, Sources.NSClient,
|
||||
ValueWithUnit.Timestamp(it.timestamp)
|
||||
)
|
||||
aapsLogger.debug(LTag.DATABASE, "Invalidated ProfileSwitch $it")
|
||||
}
|
||||
result.updatedNsId.forEach {
|
||||
|
@ -435,21 +457,24 @@ class NSClientAddUpdateWorker(
|
|||
.blockingGet()
|
||||
.also { result ->
|
||||
result.inserted.forEach { oe ->
|
||||
uel.log(Action.LOOP_CHANGE, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.LOOP_CHANGE, Sources.NSClient,
|
||||
ValueWithUnit.OfflineEventReason(oe.reason),
|
||||
ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(oe.duration).toInt())
|
||||
)
|
||||
aapsLogger.debug(LTag.DATABASE, "Inserted OfflineEvent $oe")
|
||||
}
|
||||
result.invalidated.forEach { oe ->
|
||||
uel.log(Action.LOOP_REMOVED, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.LOOP_REMOVED, Sources.NSClient,
|
||||
ValueWithUnit.OfflineEventReason(oe.reason),
|
||||
ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(oe.duration).toInt())
|
||||
)
|
||||
aapsLogger.debug(LTag.DATABASE, "Invalidated OfflineEvent $oe")
|
||||
}
|
||||
result.ended.forEach { oe ->
|
||||
uel.log(Action.LOOP_CHANGE, Sources.NSClient,
|
||||
uel.log(
|
||||
Action.LOOP_CHANGE, Sources.NSClient,
|
||||
ValueWithUnit.OfflineEventReason(oe.reason),
|
||||
ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(oe.duration).toInt())
|
||||
)
|
||||
|
@ -472,7 +497,8 @@ class NSClientAddUpdateWorker(
|
|||
val enteredBy = JsonHelper.safeGetString(json, "enteredBy", "")
|
||||
val notes = JsonHelper.safeGetString(json, "notes", "")
|
||||
if (date > now - 15 * 60 * 1000L && notes.isNotEmpty()
|
||||
&& enteredBy != sp.getString("careportal_enteredby", "AndroidAPS")) {
|
||||
&& enteredBy != sp.getString("careportal_enteredby", "AndroidAPS")
|
||||
) {
|
||||
val defaultVal = config.NSCLIENT
|
||||
if (sp.getBoolean(R.string.key_ns_announcements, defaultVal)) {
|
||||
val announcement = Notification(Notification.NS_ANNOUNCEMENT, notes, Notification.ANNOUNCEMENT, 60)
|
||||
|
|
Loading…
Reference in a new issue