TimeUnit for ms-> min conversion
This commit is contained in:
parent
f8a38889a3
commit
1876a6064c
|
@ -8,7 +8,7 @@ import info.nightscout.androidaps.R
|
|||
import info.nightscout.androidaps.database.AppRepository
|
||||
import info.nightscout.androidaps.database.entities.TherapyEvent
|
||||
import info.nightscout.androidaps.database.entities.UserEntry
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||
import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction
|
||||
import info.nightscout.androidaps.database.transactions.SyncTherapyEventTransaction
|
||||
import info.nightscout.androidaps.events.EventNsTreatment
|
||||
|
@ -28,6 +28,7 @@ import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
|||
import info.nightscout.androidaps.utils.extensions.temporaryTargetFromJson
|
||||
import info.nightscout.androidaps.utils.extensions.therapyEventFromJson
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
class NSClientAddUpdateWorker(
|
||||
|
@ -86,27 +87,27 @@ class NSClientAddUpdateWorker(
|
|||
.blockingGet()
|
||||
.also { result ->
|
||||
result.inserted.forEach {
|
||||
uel.log(UserEntry.Action.TT, ValueWithUnit(UserEntry.Sources.NSClient),
|
||||
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
|
||||
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
|
||||
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
|
||||
ValueWithUnit(it.duration.toInt() / 60000, UserEntry.Units.M, true)
|
||||
uel.log(Action.TT, ValueWithUnit(Sources.NSClient),
|
||||
ValueWithUnit(it.reason.text, Units.TherapyEvent),
|
||||
ValueWithUnit(it.lowTarget, Units.Mg_Dl, true),
|
||||
ValueWithUnit(it.highTarget, Units.Mg_Dl, it.lowTarget != it.highTarget),
|
||||
ValueWithUnit(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt(), Units.M, true)
|
||||
)
|
||||
}
|
||||
result.invalidated.forEach {
|
||||
uel.log(UserEntry.Action.TT_REMOVED, ValueWithUnit(UserEntry.Sources.NSClient),
|
||||
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
|
||||
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
|
||||
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
|
||||
ValueWithUnit(it.duration.toInt() / 60000, UserEntry.Units.M, true)
|
||||
uel.log(Action.TT_REMOVED, ValueWithUnit(Sources.NSClient),
|
||||
ValueWithUnit(it.reason.text, Units.TherapyEvent),
|
||||
ValueWithUnit(it.lowTarget, Units.Mg_Dl, true),
|
||||
ValueWithUnit(it.highTarget, Units.Mg_Dl, it.lowTarget != it.highTarget),
|
||||
ValueWithUnit(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt(), Units.M, true)
|
||||
)
|
||||
}
|
||||
result.ended.forEach {
|
||||
uel.log(UserEntry.Action.CANCEL_TT, ValueWithUnit(UserEntry.Sources.NSClient),
|
||||
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
|
||||
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
|
||||
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
|
||||
ValueWithUnit(it.duration.toInt() / 60000, UserEntry.Units.M, true)
|
||||
uel.log(Action.CANCEL_TT, ValueWithUnit(Sources.NSClient),
|
||||
ValueWithUnit(it.reason.text, Units.TherapyEvent),
|
||||
ValueWithUnit(it.lowTarget, Units.Mg_Dl, true),
|
||||
ValueWithUnit(it.highTarget, Units.Mg_Dl, it.lowTarget != it.highTarget),
|
||||
ValueWithUnit(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt(), Units.M, true)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -131,17 +132,17 @@ class NSClientAddUpdateWorker(
|
|||
.blockingGet()
|
||||
.also { result ->
|
||||
result.inserted.forEach {
|
||||
uel.log(UserEntry.Action.CAREPORTAL,
|
||||
it.note ?: "", ValueWithUnit(UserEntry.Sources.NSClient),
|
||||
ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true),
|
||||
ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent)
|
||||
uel.log(Action.CAREPORTAL,
|
||||
it.note ?: "", ValueWithUnit(Sources.NSClient),
|
||||
ValueWithUnit(it.timestamp, Units.Timestamp, true),
|
||||
ValueWithUnit(it.type.text, Units.TherapyEvent)
|
||||
)
|
||||
}
|
||||
result.invalidated.forEach {
|
||||
uel.log(UserEntry.Action.CAREPORTAL_REMOVED,
|
||||
it.note ?: "", ValueWithUnit(UserEntry.Sources.NSClient),
|
||||
ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true),
|
||||
ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent)
|
||||
it.note ?: "", ValueWithUnit(Sources.NSClient),
|
||||
ValueWithUnit(it.timestamp, Units.Timestamp, true),
|
||||
ValueWithUnit(it.type.text, Units.TherapyEvent)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
|||
import info.nightscout.androidaps.utils.extensions.temporaryTargetFromNsIdForInvalidating
|
||||
import info.nightscout.androidaps.utils.extensions.therapyEventFromNsIdForInvalidating
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
// This will not be needed fpr NS v3
|
||||
|
@ -72,7 +73,7 @@ class NSClientRemoveWorker(
|
|||
ValueWithUnit(it.reason.text, Units.TherapyEvent),
|
||||
ValueWithUnit(it.lowTarget, Units.Mg_Dl, true),
|
||||
ValueWithUnit(it.highTarget, Units.Mg_Dl, it.lowTarget != it.highTarget),
|
||||
ValueWithUnit(it.duration.toInt() / 60000, UserEntry.Units.M, it.duration != 0L)
|
||||
ValueWithUnit(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt(), Units.M, it.duration != 0L)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue