fix TherapyEvent upload
This commit is contained in:
parent
76641649ed
commit
a70f24a68a
2 changed files with 4 additions and 4 deletions
|
@ -360,10 +360,10 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
when {
|
when {
|
||||||
// without nsId = create new
|
// without nsId = create new
|
||||||
te.first.interfaceIDs.nightscoutId == null ->
|
te.first.interfaceIDs.nightscoutId == null ->
|
||||||
nsClientPlugin.nsClientService?.dbAdd("treatments", te.first.toJson(true), DataSyncSelector.PairTherapyEvent(te.first, te.second), "$startId/$lastDbId")
|
nsClientPlugin.nsClientService?.dbAdd("treatments", te.first.toJson(true, dateUtil), DataSyncSelector.PairTherapyEvent(te.first, te.second), "$startId/$lastDbId")
|
||||||
// nsId = update
|
// nsId = update
|
||||||
te.first.interfaceIDs.nightscoutId != null ->
|
te.first.interfaceIDs.nightscoutId != null ->
|
||||||
nsClientPlugin.nsClientService?.dbUpdate("treatments", te.first.interfaceIDs.nightscoutId, te.first.toJson(false), DataSyncSelector.PairTherapyEvent(te.first, te.second), "$startId/$lastDbId")
|
nsClientPlugin.nsClientService?.dbUpdate("treatments", te.first.interfaceIDs.nightscoutId, te.first.toJson(false, dateUtil), DataSyncSelector.PairTherapyEvent(te.first, te.second), "$startId/$lastDbId")
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,11 +97,11 @@ fun therapyEventFromJson(jsonObject: JSONObject): TherapyEvent? {
|
||||||
return te
|
return te
|
||||||
}
|
}
|
||||||
|
|
||||||
fun TherapyEvent.toJson(isAdd: Boolean): JSONObject =
|
fun TherapyEvent.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject =
|
||||||
JSONObject()
|
JSONObject()
|
||||||
.put("eventType", type.text)
|
.put("eventType", type.text)
|
||||||
.put("isValid", isValid)
|
.put("isValid", isValid)
|
||||||
.put("created_at", timestamp)
|
.put("created_at", dateUtil.toISOString(timestamp))
|
||||||
.put("enteredBy", enteredBy)
|
.put("enteredBy", enteredBy)
|
||||||
.put("units", if (glucoseUnit == TherapyEvent.GlucoseUnit.MGDL) Constants.MGDL else Constants.MMOL)
|
.put("units", if (glucoseUnit == TherapyEvent.GlucoseUnit.MGDL) Constants.MGDL else Constants.MMOL)
|
||||||
.also {
|
.also {
|
||||||
|
|
Loading…
Reference in a new issue