fix TherapyEvent upload
This commit is contained in:
parent
76641649ed
commit
a70f24a68a
|
@ -360,10 +360,10 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
when {
|
||||
// without nsId = create new
|
||||
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
|
||||
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
|
||||
}
|
||||
|
|
|
@ -97,11 +97,11 @@ fun therapyEventFromJson(jsonObject: JSONObject): TherapyEvent? {
|
|||
return te
|
||||
}
|
||||
|
||||
fun TherapyEvent.toJson(isAdd: Boolean): JSONObject =
|
||||
fun TherapyEvent.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject =
|
||||
JSONObject()
|
||||
.put("eventType", type.text)
|
||||
.put("isValid", isValid)
|
||||
.put("created_at", timestamp)
|
||||
.put("created_at", dateUtil.toISOString(timestamp))
|
||||
.put("enteredBy", enteredBy)
|
||||
.put("units", if (glucoseUnit == TherapyEvent.GlucoseUnit.MGDL) Constants.MGDL else Constants.MMOL)
|
||||
.also {
|
||||
|
|
Loading…
Reference in a new issue