Update uel.log NSClientAddUpdateWorker

This commit is contained in:
Philoul 2021-04-06 00:43:51 +02:00
parent 7b4ebbd440
commit e490c2df04
7 changed files with 33 additions and 17 deletions

View file

@ -85,14 +85,14 @@ class NSClientAddUpdateWorker(
.blockingGet() .blockingGet()
.also { result -> .also { result ->
result.inserted.forEach { result.inserted.forEach {
uel.log(Action.CAREPORTAL, Sources.NSClient, uel.log(Action.BOLUS, Sources.NSClient,
ValueWithUnit.Timestamp(it.timestamp), ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.Insulin(it.amount) ValueWithUnit.Insulin(it.amount)
) )
aapsLogger.debug(LTag.DATABASE, "Inserted bolus $it") aapsLogger.debug(LTag.DATABASE, "Inserted bolus $it")
} }
result.invalidated.forEach { result.invalidated.forEach {
uel.log(Action.CAREPORTAL_REMOVED, Sources.NSClient, uel.log(Action.BOLUS_REMOVED, Sources.NSClient,
ValueWithUnit.Timestamp(it.timestamp), ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.Insulin(it.amount) ValueWithUnit.Insulin(it.amount)
) )
@ -114,14 +114,14 @@ class NSClientAddUpdateWorker(
.blockingGet() .blockingGet()
.also { result -> .also { result ->
result.inserted.forEach { result.inserted.forEach {
uel.log(Action.CAREPORTAL, Sources.NSClient, uel.log(Action.CARBS, Sources.NSClient,
ValueWithUnit.Timestamp(it.timestamp), ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.Gram(it.amount.toInt()) ValueWithUnit.Gram(it.amount.toInt())
) )
aapsLogger.debug(LTag.DATABASE, "Inserted carbs $it") aapsLogger.debug(LTag.DATABASE, "Inserted carbs $it")
} }
result.invalidated.forEach { result.invalidated.forEach {
uel.log(Action.CAREPORTAL, Sources.NSClient, uel.log(Action.CARBS_REMOVED, Sources.NSClient,
ValueWithUnit.Timestamp(it.timestamp), ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.Gram(it.amount.toInt()) ValueWithUnit.Gram(it.amount.toInt())
) )
@ -194,8 +194,13 @@ class NSClientAddUpdateWorker(
} }
.blockingGet() .blockingGet()
.also { result -> .also { result ->
val action = when (eventType) {
TherapyEvent.Type.CANNULA_CHANGE.text -> Action.SITE_CHANGE
TherapyEvent.Type.INSULIN_CHANGE.text -> Action.RESERVOIR_CHANGE
else -> Action.CAREPORTAL
}
result.inserted.forEach { result.inserted.forEach {
uel.log(Action.CAREPORTAL, Sources.NSClient, uel.log(action, Sources.NSClient,
it.note ?: "", it.note ?: "",
ValueWithUnit.Timestamp(it.timestamp), ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.TherapyEventType(it.type) ValueWithUnit.TherapyEventType(it.type)
@ -225,7 +230,7 @@ class NSClientAddUpdateWorker(
.blockingGet() .blockingGet()
.also { result -> .also { result ->
result.inserted.forEach { result.inserted.forEach {
uel.log(Action.CAREPORTAL, Sources.NSClient, uel.log(Action.TEMP_BASAL, Sources.NSClient,
ValueWithUnit.Timestamp(it.timestamp), ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.UnitPerHour(it.rate), ValueWithUnit.UnitPerHour(it.rate),
ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt()) ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt())
@ -233,7 +238,7 @@ class NSClientAddUpdateWorker(
aapsLogger.debug(LTag.DATABASE, "Inserted TemporaryBasal $it") aapsLogger.debug(LTag.DATABASE, "Inserted TemporaryBasal $it")
} }
result.invalidated.forEach { result.invalidated.forEach {
uel.log(Action.CAREPORTAL, Sources.NSClient, uel.log(Action.TEMP_BASAL_REMOVED, Sources.NSClient,
ValueWithUnit.Timestamp(it.timestamp), ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.UnitPerHour(it.rate), ValueWithUnit.UnitPerHour(it.rate),
ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt()) ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt())
@ -241,7 +246,7 @@ class NSClientAddUpdateWorker(
aapsLogger.debug(LTag.DATABASE, "Invalidated TemporaryBasal $it") aapsLogger.debug(LTag.DATABASE, "Invalidated TemporaryBasal $it")
} }
result.ended.forEach { result.ended.forEach {
uel.log(Action.CAREPORTAL, Sources.NSClient, uel.log(Action.CANCEL_TEMP_BASAL, Sources.NSClient,
ValueWithUnit.Timestamp(it.timestamp), ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.UnitPerHour(it.rate), ValueWithUnit.UnitPerHour(it.rate),
ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt()) ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt())
@ -263,24 +268,27 @@ class NSClientAddUpdateWorker(
.blockingGet() .blockingGet()
.also { result -> .also { result ->
result.inserted.forEach { result.inserted.forEach {
uel.log(Action.CAREPORTAL, Sources.NSClient, uel.log(Action.EXTENDED_BOLUS, Sources.NSClient,
ValueWithUnit.Timestamp(it.timestamp), ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.Insulin(it.amount),
ValueWithUnit.UnitPerHour(it.rate), ValueWithUnit.UnitPerHour(it.rate),
ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt()) ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt())
) )
aapsLogger.debug(LTag.DATABASE, "Inserted ExtendedBolus $it") aapsLogger.debug(LTag.DATABASE, "Inserted ExtendedBolus $it")
} }
result.invalidated.forEach { result.invalidated.forEach {
uel.log(Action.CAREPORTAL, Sources.NSClient, uel.log(Action.EXTENDED_BOLUS_REMOVED, Sources.NSClient,
ValueWithUnit.Timestamp(it.timestamp), ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.Insulin(it.amount),
ValueWithUnit.UnitPerHour(it.rate), ValueWithUnit.UnitPerHour(it.rate),
ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt()) ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt())
) )
aapsLogger.debug(LTag.DATABASE, "Invalidated ExtendedBolus $it") aapsLogger.debug(LTag.DATABASE, "Invalidated ExtendedBolus $it")
} }
result.ended.forEach { result.ended.forEach {
uel.log(Action.CAREPORTAL, Sources.NSClient, uel.log(Action.CANCEL_EXTENDED_BOLUS, Sources.NSClient,
ValueWithUnit.Timestamp(it.timestamp), ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.Insulin(it.amount),
ValueWithUnit.UnitPerHour(it.rate), ValueWithUnit.UnitPerHour(it.rate),
ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt()) ValueWithUnit.Minute(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt())
) )

View file

@ -334,10 +334,10 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() {
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(bolus.timestamp) resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(bolus.timestamp)
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
uel.log( uel.log(
Action.TREATMENT_REMOVED, Sources.Treatments, Action.BOLUS_REMOVED, Sources.Treatments,
ValueWithUnit.Timestamp(bolus.timestamp), ValueWithUnit.Timestamp(bolus.timestamp),
ValueWithUnit.Insulin(bolus.amount) ValueWithUnit.Insulin(bolus.amount)
//XXXValueWithUnit.Gram(mealLinkLoaded.carbs.toInt()) //ValueWithUnit.Gram(mealLinkLoaded.carbs.toInt())
) )
disposable += repository.runTransactionForResult(InvalidateBolusTransaction(bolus.id)) disposable += repository.runTransactionForResult(InvalidateBolusTransaction(bolus.id))
.subscribe( .subscribe(
@ -356,7 +356,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() {
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(carb.timestamp) resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(carb.timestamp)
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
uel.log( uel.log(
Action.TREATMENT_REMOVED, Sources.Treatments, Action.CARBS_REMOVED, Sources.Treatments,
ValueWithUnit.Timestamp(carb.timestamp), ValueWithUnit.Timestamp(carb.timestamp),
ValueWithUnit.Gram(carb.amount.toInt())) ValueWithUnit.Gram(carb.amount.toInt()))
disposable += repository.runTransactionForResult(InvalidateCarbsTransaction(carb.id)) disposable += repository.runTransactionForResult(InvalidateCarbsTransaction(carb.id))

View file

@ -170,7 +170,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(tempBasal.timestamp)} ${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(tempBasal.timestamp)}
""".trimIndent(), """.trimIndent(),
{ _: DialogInterface?, _: Int -> { _: DialogInterface?, _: Int ->
uel.log(Action.TT_REMOVED, Sources.Treatments, uel.log(Action.TEMP_BASAL_REMOVED, Sources.Treatments,
ValueWithUnit.Timestamp(tempBasal.timestamp)) ValueWithUnit.Timestamp(tempBasal.timestamp))
disposable += repository.runTransactionForResult(InvalidateTemporaryBasalTransaction(tempBasal.id)) disposable += repository.runTransactionForResult(InvalidateTemporaryBasalTransaction(tempBasal.id))
.subscribe( .subscribe(

View file

@ -61,6 +61,9 @@ class Translator @Inject internal constructor(
Action.AUTOMATION_REMOVED -> resourceHelper.gs(R.string.uel_automation_removed) Action.AUTOMATION_REMOVED -> resourceHelper.gs(R.string.uel_automation_removed)
Action.BG_REMOVED -> resourceHelper.gs(R.string.uel_bg_removed) Action.BG_REMOVED -> resourceHelper.gs(R.string.uel_bg_removed)
Action.CAREPORTAL_REMOVED -> resourceHelper.gs(R.string.uel_careportal_removed) Action.CAREPORTAL_REMOVED -> resourceHelper.gs(R.string.uel_careportal_removed)
Action.BOLUS_REMOVED -> resourceHelper.gs(R.string.uel_bolus_removed)
Action.CARBS_REMOVED -> resourceHelper.gs(R.string.uel_carbs_removed)
Action.TEMP_BASAL_REMOVED -> resourceHelper.gs(R.string.uel_temp_basal_removed)
Action.EXTENDED_BOLUS_REMOVED -> resourceHelper.gs(R.string.uel_extended_bolus_removed) Action.EXTENDED_BOLUS_REMOVED -> resourceHelper.gs(R.string.uel_extended_bolus_removed)
Action.FOOD -> resourceHelper.gs(R.string.uel_food) Action.FOOD -> resourceHelper.gs(R.string.uel_food)
Action.FOOD_REMOVED -> resourceHelper.gs(R.string.uel_food_removed) Action.FOOD_REMOVED -> resourceHelper.gs(R.string.uel_food_removed)

View file

@ -106,8 +106,7 @@ class UserEntryPresentationHelper @Inject constructor(
is ValueWithUnit.UnitPerHour -> DecimalFormatter.to2Decimal(valueWithUnit.value) + translator.translate(valueWithUnit) is ValueWithUnit.UnitPerHour -> DecimalFormatter.to2Decimal(valueWithUnit.value) + translator.translate(valueWithUnit)
is ValueWithUnit.SimpleInt -> valueWithUnit.value.toString() is ValueWithUnit.SimpleInt -> valueWithUnit.value.toString()
is ValueWithUnit.SimpleString -> valueWithUnit.value is ValueWithUnit.SimpleString -> valueWithUnit.value
is ValueWithUnit.StringResource -> resourceHelper.gs(valueWithUnit.value, *(valueWithUnit.params.map { it.value() }.toTypedArray())) //Todo Fix StringResource with Param is ValueWithUnit.StringResource -> resourceHelper.gs(valueWithUnit.value, *(valueWithUnit.params.map { it.value() }.toTypedArray()))
// is XXXValueWithUnit.StringResource -> if (valueWithUnit.params.size > 0 ) valueWithUnit.params.joinToString(separator = " ") { value -> toPresentationString(value) } else resourceHelper.gs(valueWithUnit.value) //To help debugging
is ValueWithUnit.TherapyEventMeterType -> translator.translate(valueWithUnit.value) is ValueWithUnit.TherapyEventMeterType -> translator.translate(valueWithUnit.value)
is ValueWithUnit.TherapyEventTTReason -> translator.translate(valueWithUnit.value) is ValueWithUnit.TherapyEventTTReason -> translator.translate(valueWithUnit.value)
is ValueWithUnit.TherapyEventType -> translator.translate(valueWithUnit.value) is ValueWithUnit.TherapyEventType -> translator.translate(valueWithUnit.value)

View file

@ -444,6 +444,9 @@
<string name="uel_automation_removed">AUTOMATION REMOVED</string> <string name="uel_automation_removed">AUTOMATION REMOVED</string>
<string name="uel_bg_removed">BG REMOVED</string> <string name="uel_bg_removed">BG REMOVED</string>
<string name="uel_careportal_removed">CAREPORTAL REMOVED</string> <string name="uel_careportal_removed">CAREPORTAL REMOVED</string>
<string name="uel_bolus_removed">BOLUS REMOVED</string>
<string name="uel_carbs_removed">CARBS REMOVED</string>
<string name="uel_temp_basal_removed">TEMP BASAL REMOVED</string>
<string name="uel_extended_bolus_removed">EXTENDED BOLUS REMOVED</string> <string name="uel_extended_bolus_removed">EXTENDED BOLUS REMOVED</string>
<string name="uel_food">FOOD</string> <string name="uel_food">FOOD</string>
<string name="uel_food_removed">FOOD REMOVED</string> <string name="uel_food_removed">FOOD REMOVED</string>

View file

@ -67,6 +67,9 @@ data class UserEntry(
PROFILE_SWITCH_REMOVED (ColorGroup.Aaps), PROFILE_SWITCH_REMOVED (ColorGroup.Aaps),
RESTART_EVENTS_REMOVED (ColorGroup.Aaps), RESTART_EVENTS_REMOVED (ColorGroup.Aaps),
TREATMENT_REMOVED (ColorGroup.Aaps), TREATMENT_REMOVED (ColorGroup.Aaps),
BOLUS_REMOVED (ColorGroup.Aaps),
CARBS_REMOVED (ColorGroup.Aaps),
TEMP_BASAL_REMOVED (ColorGroup.Aaps),
TT_REMOVED (ColorGroup.Aaps), TT_REMOVED (ColorGroup.Aaps),
NS_PAUSED (ColorGroup.Aaps), NS_PAUSED (ColorGroup.Aaps),
NS_RESUME (ColorGroup.Aaps), NS_RESUME (ColorGroup.Aaps),