Add log() overloads to UserEntryLogger that accept a timestamp
That way, if the user is already passing the timestamp as part of the log() call's payload (in listValues), mismatches can be avoided by passing the same timestamp as the timestamp arguments in the new overloads.
This commit is contained in:
parent
9145f3a96a
commit
a6aa05b110
|
@ -9,6 +9,8 @@ import info.nightscout.interfaces.userEntry.ValueWithUnitMapper
|
|||
|
||||
interface UserEntryLogger {
|
||||
|
||||
fun log(action: Action, source: Sources, note: String?, timestamp: Long, vararg listValues: ValueWithUnit?)
|
||||
fun log(action: Action, source: Sources, note: String?, timestamp: Long, listValues: List<ValueWithUnit?>)
|
||||
fun log(action: Action, source: Sources, note: String? = "", vararg listValues: ValueWithUnit?)
|
||||
fun log(action: Action, source: Sources, vararg listValues: ValueWithUnit?)
|
||||
fun log(action: Action, source: Sources, note: String? = "", listValues: List<ValueWithUnit?> = listOf())
|
||||
|
|
|
@ -29,16 +29,14 @@ class UserEntryLoggerImpl @Inject constructor(
|
|||
|
||||
private val compositeDisposable = CompositeDisposable()
|
||||
|
||||
override fun log(action: Action, source: Sources, note: String?, vararg listValues: ValueWithUnit?) = log(action, source, note, listValues.toList())
|
||||
override fun log(action: Action, source: Sources, note: String?, timestamp: Long, vararg listValues: ValueWithUnit?) = log(action, source, note, timestamp, listValues.toList())
|
||||
|
||||
override fun log(action: Action, source: Sources, vararg listValues: ValueWithUnit?) = log(action, source, "", listValues.toList())
|
||||
|
||||
override fun log(action: Action, source: Sources, note: String?, listValues: List<ValueWithUnit?>) {
|
||||
override fun log(action: Action, source: Sources, note: String?, timestamp: Long, listValues: List<ValueWithUnit?>) {
|
||||
val filteredValues = listValues.toList().filterNotNull()
|
||||
log(
|
||||
listOf(
|
||||
UserEntry(
|
||||
timestamp = dateUtil.now(),
|
||||
timestamp = timestamp,
|
||||
action = action,
|
||||
source = source,
|
||||
note = note ?: "",
|
||||
|
@ -48,6 +46,12 @@ class UserEntryLoggerImpl @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
override fun log(action: Action, source: Sources, note: String?, vararg listValues: ValueWithUnit?) = log(action, source, note, listValues.toList())
|
||||
|
||||
override fun log(action: Action, source: Sources, vararg listValues: ValueWithUnit?) = log(action, source, "", listValues.toList())
|
||||
|
||||
override fun log(action: Action, source: Sources, note: String?, listValues: List<ValueWithUnit?>) = log(action, source, note, dateUtil.now(), listValues)
|
||||
|
||||
override fun log(entries: List<UserEntry>) {
|
||||
compositeDisposable += repository.runTransactionForResult(UserEntryTransaction(entries))
|
||||
.subscribeOn(aapsSchedulers.io)
|
||||
|
|
|
@ -273,7 +273,13 @@ class PumpSyncImplementation @Inject constructor(
|
|||
pumpSerial = pumpSerial
|
||||
)
|
||||
)
|
||||
uel.log(UserEntry.Action.CAREPORTAL, pumpType.source.toDbSource(), note, ValueWithUnit.Timestamp(timestamp), ValueWithUnit.TherapyEventType(type.toDBbEventType()))
|
||||
uel.log(
|
||||
action = UserEntry.Action.CAREPORTAL,
|
||||
source = pumpType.source.toDbSource(),
|
||||
note = note,
|
||||
timestamp = timestamp,
|
||||
ValueWithUnit.Timestamp(timestamp), ValueWithUnit.TherapyEventType(type.toDBbEventType())
|
||||
)
|
||||
repository.runTransactionForResult(InsertIfNewByTimestampTherapyEventTransaction(therapyEvent))
|
||||
.doOnError {
|
||||
aapsLogger.error(LTag.DATABASE, "Error while saving TherapyEvent", it)
|
||||
|
|
Loading…
Reference in a new issue