Add EventTime if changed (Carbs, TT, CP, PS)

This commit is contained in:
Philoul 2021-03-03 21:16:37 +01:00
parent a556df86c5
commit db1b3b7328
4 changed files with 28 additions and 10 deletions

View file

@ -250,7 +250,10 @@ class CarbsDialog : DialogFragmentWithDate() {
}
if (carbsAfterConstraints > 0) {
if (duration == 0) {
uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset, Units.M))
if (eventTimeChanged)
uel.log(Action.CARBS, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset, Units.M))
else
uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset, Units.M))
carbsGenerator.createCarb(carbsAfterConstraints, time, CareportalEvent.CARBCORRECTION, notes)
} else {
uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset,Units.M), ValueWithUnit(duration, Units.H))

View file

@ -223,7 +223,10 @@ class CareDialog : DialogFragmentWithDate() {
EventType.ANNOUNCEMENT -> CareportalEvent.ANNOUNCEMENT
}
careportalEvent.json = json.toString()
uel.log(Action.CAREPORTAL, notes, ValueWithUnit(careportalEvent.eventType, Units.CPEvent))
if (eventTimeChanged)
uel.log(Action.CAREPORTAL, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(careportalEvent.eventType, Units.CPEvent))
else
uel.log(Action.CAREPORTAL, notes, ValueWithUnit(careportalEvent.eventType, Units.CPEvent))
MainApp.getDbHelper().createOrUpdate(careportalEvent)
nsUpload.uploadCareportalEntryToNS(json)
}, null)

View file

@ -125,7 +125,10 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
uel.log(Action.PROFILE_SWITCH, notes, ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H), ValueWithUnit(duration, Units.M))
if (eventTimeChanged)
uel.log(Action.PROFILE_SWITCH, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H), ValueWithUnit(duration, Units.M))
else
uel.log(Action.PROFILE_SWITCH, notes, ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H), ValueWithUnit(duration, Units.M))
treatmentsPlugin.doProfileSwitch(profileStore, profile, duration, percent, timeShift, eventTime)
})
}

View file

@ -168,13 +168,22 @@ class TempTargetDialog : DialogFragmentWithDate() {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
val units = profileFunction.getUnits()
when(reason) {
resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT_EATING_SOON, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.activity) -> uel.log(Action.TT_ACTIVITY, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT_HYPO, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT)
}
if (eventTimeChanged)
when(reason) {
resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT_EATING_SOON, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.activity) -> uel.log(Action.TT_ACTIVITY, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT_HYPO, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, ValueWithUnit(eventTime, Units.Timestamp))
}
else
when(reason) {
resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT_EATING_SOON, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.activity) -> uel.log(Action.TT_ACTIVITY, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT_HYPO, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT)
}
if (target == 0.0 || duration == 0) {
val tempTarget = TempTarget()
.date(eventTime)