commit
5924be585e
1 changed files with 54 additions and 56 deletions
|
@ -157,7 +157,8 @@ class OpenHumansUploader @Inject constructor(
|
|||
super.onStop()
|
||||
}
|
||||
|
||||
fun enqueueBGReading(bgReading: BgReading) = insertQueueItem("BgReadings") {
|
||||
fun enqueueBGReading(bgReading: BgReading?) = bgReading?.let {
|
||||
insertQueueItem("BgReadings") {
|
||||
put("date", bgReading.date)
|
||||
put("isValid", bgReading.isValid)
|
||||
put("value", bgReading.value)
|
||||
|
@ -166,9 +167,11 @@ class OpenHumansUploader @Inject constructor(
|
|||
put("source", bgReading.source)
|
||||
put("nsId", bgReading._id)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun enqueueTreatment(treatment: Treatment, deleted: Boolean = false) = insertQueueItem("Treatments") {
|
||||
fun enqueueTreatment(treatment: Treatment?, deleted: Boolean = false) = treatment?.let {
|
||||
insertQueueItem("Treatments") {
|
||||
put("date", treatment.date)
|
||||
put("isValid", treatment.isValid)
|
||||
put("source", treatment.source)
|
||||
|
@ -183,6 +186,7 @@ class OpenHumansUploader @Inject constructor(
|
|||
put("bolusCalcJson", treatment.getBoluscalc())
|
||||
put("isDeletion", deleted)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun enqueueCareportalEvent(careportalEvent: CareportalEvent, deleted: Boolean = false) = insertQueueItem("CareportalEvents") {
|
||||
|
@ -240,7 +244,8 @@ class OpenHumansUploader @Inject constructor(
|
|||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun enqueueTemporaryBasal(temporaryBasal: TemporaryBasal, deleted: Boolean = false) = insertQueueItem("TemporaryBasals") {
|
||||
fun enqueueTemporaryBasal(temporaryBasal: TemporaryBasal?, deleted: Boolean = false) = temporaryBasal?.let {
|
||||
insertQueueItem("TemporaryBasals") {
|
||||
put("date", temporaryBasal.date)
|
||||
put("isValid", temporaryBasal.isValid)
|
||||
put("source", temporaryBasal.source)
|
||||
|
@ -253,9 +258,11 @@ class OpenHumansUploader @Inject constructor(
|
|||
put("absoluteRate", temporaryBasal.absoluteRate)
|
||||
put("isDeletion", deleted)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun enqueueTempTarget(tempTarget: TempTarget, deleted: Boolean = false) = insertQueueItem("TempTargets") {
|
||||
fun enqueueTempTarget(tempTarget: TempTarget?, deleted: Boolean = false) = tempTarget?.let {
|
||||
insertQueueItem("TempTargets") {
|
||||
put("date", tempTarget.date)
|
||||
put("isValid", tempTarget.isValid)
|
||||
put("source", tempTarget.source)
|
||||
|
@ -266,8 +273,9 @@ class OpenHumansUploader @Inject constructor(
|
|||
put("durationInMinutes", tempTarget.durationInMinutes)
|
||||
put("isDeletion", deleted)
|
||||
}
|
||||
}
|
||||
|
||||
fun enqueueSMBData(profile: JSONObject, glucoseStatus: JSONObject, iobData: JSONArray, mealData: JSONObject, currentTemp: JSONObject, autosensData: JSONObject, smbAllowed: Boolean, smbAlwaysAllowed: Boolean, result: JSONObject) = insertQueueItem("APSData") {
|
||||
fun enqueueSMBData(profile: JSONObject?, glucoseStatus: JSONObject?, iobData: JSONArray?, mealData: JSONObject?, currentTemp: JSONObject?, autosensData: JSONObject?, smbAllowed: Boolean, smbAlwaysAllowed: Boolean, result: JSONObject?) = insertQueueItem("APSData") {
|
||||
put("algorithm", "SMB")
|
||||
put("profile", profile)
|
||||
put("glucoseStatus", glucoseStatus)
|
||||
|
@ -280,7 +288,7 @@ class OpenHumansUploader @Inject constructor(
|
|||
put("result", result)
|
||||
}
|
||||
|
||||
fun enqueueAMAData(profile: JSONObject, glucoseStatus: JSONObject, iobData: JSONArray, mealData: JSONObject, currentTemp: JSONObject, autosensData: JSONObject, result: JSONObject) = insertQueueItem("APSData") {
|
||||
fun enqueueAMAData(profile: JSONObject?, glucoseStatus: JSONObject?, iobData: JSONArray?, mealData: JSONObject?, currentTemp: JSONObject?, autosensData: JSONObject?, result: JSONObject?) = insertQueueItem("APSData") {
|
||||
put("algorithm", "AMA")
|
||||
put("profile", profile)
|
||||
put("glucoseStatus", glucoseStatus)
|
||||
|
@ -291,16 +299,6 @@ class OpenHumansUploader @Inject constructor(
|
|||
put("result", result)
|
||||
}
|
||||
|
||||
fun enqueueMAData(profile: JSONObject, glucoseStatus: JSONObject, iobData: JSONObject, mealData: JSONObject, currentTemp: JSONObject, result: JSONObject) = insertQueueItem("APSData") {
|
||||
put("algorithm", "MA")
|
||||
put("profile", profile)
|
||||
put("glucoseStatus", glucoseStatus)
|
||||
put("iobData", iobData)
|
||||
put("mealData", mealData)
|
||||
put("currentTemp", currentTemp)
|
||||
put("result", result)
|
||||
}
|
||||
|
||||
private fun insertQueueItem(file: String, structureVersion: Int = 1, generator: JSONObject.() -> Unit) {
|
||||
if (oAuthTokens != null && this.isEnabled(PluginType.GENERAL)) {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue