Fix null XXXValueWithUnit and aapsLogger string

This commit is contained in:
Philoul 2021-04-01 20:17:11 +02:00
parent 83f4d25527
commit bb3effcda3
2 changed files with 27 additions and 24 deletions

View file

@ -27,17 +27,18 @@ class UserEntryLogger @Inject constructor(
} }
fun log(action: Action, source: Sources, note: String? ="", vararg listvalues: XXXValueWithUnit?) { fun log(action: Action, source: Sources, note: String? ="", vararg listvalues: XXXValueWithUnit?) {
val filteredValues = listvalues.toList().filter { it != null}
compositeDisposable += repository.runTransaction(UserEntryTransaction( compositeDisposable += repository.runTransaction(UserEntryTransaction(
action = action, action = action,
source = source, source = source,
note = note ?:"", note = note ?:"",
values = listvalues.toList() values = filteredValues
)) ))
.subscribeOn(aapsSchedulers.io) .subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribeBy( .subscribeBy(
onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $source $note $listvalues") }, onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $source $note $filteredValues") },
onComplete = { aapsLogger.debug("USER ENTRY: $action $source $note $listvalues") } onComplete = { aapsLogger.debug("USER ENTRY: $action $source $note $filteredValues") }
) )
} }
@ -46,17 +47,18 @@ class UserEntryLogger @Inject constructor(
} }
fun log(action: Action, source: Sources, vararg listvalues: XXXValueWithUnit?) { fun log(action: Action, source: Sources, vararg listvalues: XXXValueWithUnit?) {
val filteredValues = listvalues.toList().filter { it != null}
compositeDisposable += repository.runTransaction(UserEntryTransaction( compositeDisposable += repository.runTransaction(UserEntryTransaction(
action = action, action = action,
source = source, source = source,
note = "", note = "",
values = listvalues.toList() values = filteredValues
)) ))
.subscribeOn(aapsSchedulers.io) .subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribeBy( .subscribeBy(
onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $source $listvalues") }, onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $source $filteredValues") },
onComplete = { aapsLogger.debug("USER ENTRY: $action $source $listvalues") } onComplete = { aapsLogger.debug("USER ENTRY: $action $source $filteredValues") }
) )
} }
@ -68,7 +70,7 @@ class UserEntryLogger @Inject constructor(
action = action, action = action,
source = source, source = source,
note = note ?:"", note = note ?:"",
values = mutableListOf() values = listOf()
)) ))
.subscribeOn(aapsSchedulers.io) .subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
@ -81,18 +83,19 @@ class UserEntryLogger @Inject constructor(
@Deprecated("Use XXXValueWithUnits") @Deprecated("Use XXXValueWithUnits")
fun log(action: Action, s: String? = "", values: MutableList<ValueWithUnit>) {} fun log(action: Action, s: String? = "", values: MutableList<ValueWithUnit>) {}
fun log(action: Action, source: Sources, note: String? ="", values: MutableList<XXXValueWithUnit?>) { fun log(action: Action, source: Sources, note: String? ="", listvalues: MutableList<XXXValueWithUnit?>) {
val filteredValues = listvalues.toList().filter { it != null}
compositeDisposable += repository.runTransaction(UserEntryTransaction( compositeDisposable += repository.runTransaction(UserEntryTransaction(
action = action, action = action,
source = source, source = source,
note = note ?: "", note = note ?: "",
values = values values = filteredValues
)) ))
.subscribeOn(aapsSchedulers.io) .subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribeBy( .subscribeBy(
onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $source $note $values") }, onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $source $note $filteredValues") },
onComplete = { aapsLogger.debug("USER ENTRY: $action $source $note $values") } onComplete = { aapsLogger.debug("USER ENTRY: $action $source $note $filteredValues") }
) )
} }
} }

View file

@ -10,31 +10,31 @@ sealed class XXXValueWithUnit {
data class SimpleInt(val value: Int) : XXXValueWithUnit() // formerly one usage of None data class SimpleInt(val value: Int) : XXXValueWithUnit() // formerly one usage of None
class Mgdl(val value: Double) : XXXValueWithUnit() data class Mgdl(val value: Double) : XXXValueWithUnit()
class Mmoll(val value: Double) : XXXValueWithUnit() data class Mmoll(val value: Double) : XXXValueWithUnit()
class Timestamp(val value: Long) : XXXValueWithUnit() data class Timestamp(val value: Long) : XXXValueWithUnit()
class Insulin(val value: Double) : XXXValueWithUnit() data class Insulin(val value: Double) : XXXValueWithUnit()
class UnitPerHour(val value: Double) : XXXValueWithUnit() data class UnitPerHour(val value: Double) : XXXValueWithUnit()
class Gram(val value: Int) : XXXValueWithUnit() data class Gram(val value: Int) : XXXValueWithUnit()
class Minute(val value: Int) : XXXValueWithUnit() data class Minute(val value: Int) : XXXValueWithUnit()
class Hour(val value: Int) : XXXValueWithUnit() data class Hour(val value: Int) : XXXValueWithUnit()
class Percent(val value: Int) : XXXValueWithUnit() data class Percent(val value: Int) : XXXValueWithUnit()
class TherapyEventType(val value: TherapyEvent.Type) : XXXValueWithUnit() data class TherapyEventType(val value: TherapyEvent.Type) : XXXValueWithUnit()
class TherapyEventMeterType(val value: TherapyEvent.MeterType) : XXXValueWithUnit() data class TherapyEventMeterType(val value: TherapyEvent.MeterType) : XXXValueWithUnit()
class TherapyEventTTReason(val value: TemporaryTarget.Reason) : XXXValueWithUnit() data class TherapyEventTTReason(val value: TemporaryTarget.Reason) : XXXValueWithUnit()
class StringResource(@StringRes val value: Int, val params: List<XXXValueWithUnit> = listOf()) : XXXValueWithUnit() data class StringResource(@StringRes val value: Int, val params: List<XXXValueWithUnit> = listOf()) : XXXValueWithUnit()
companion object { companion object {