Handle NS TempTarget sync properly
This commit is contained in:
parent
e2e74c0014
commit
517b9a9fa7
2 changed files with 9 additions and 6 deletions
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.db;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.DatabaseUtils;
|
import android.database.DatabaseUtils;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
|
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
|
||||||
|
@ -772,8 +773,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
TempTarget tempTarget = new TempTarget()
|
TempTarget tempTarget = new TempTarget()
|
||||||
.date(trJson.getLong("mills"))
|
.date(trJson.getLong("mills"))
|
||||||
.duration(JsonHelper.safeGetInt(trJson, "duration"))
|
.duration(JsonHelper.safeGetInt(trJson, "duration"))
|
||||||
.low(Profile.toMgdl(trJson.getDouble("targetBottom"), units))
|
.low(Profile.toMgdl(JsonHelper.safeGetDouble(trJson, "targetBottom"), units))
|
||||||
.high(Profile.toMgdl(trJson.getDouble("targetTop"), units))
|
.high(Profile.toMgdl(JsonHelper.safeGetDouble(trJson, "targetTop"), units))
|
||||||
.reason(JsonHelper.safeGetString(trJson, "reason", ""))
|
.reason(JsonHelper.safeGetString(trJson, "reason", ""))
|
||||||
._id(trJson.getString("_id"))
|
._id(trJson.getString("_id"))
|
||||||
.source(Source.NIGHTSCOUT);
|
.source(Source.NIGHTSCOUT);
|
||||||
|
|
|
@ -315,11 +315,13 @@ public class NSUpload {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
data.put("eventType", CareportalEvent.TEMPORARYTARGET);
|
data.put("eventType", CareportalEvent.TEMPORARYTARGET);
|
||||||
data.put("duration", tempTarget.durationInMinutes);
|
data.put("duration", tempTarget.durationInMinutes);
|
||||||
data.put("reason", tempTarget.reason);
|
if (tempTarget.low > 0) {
|
||||||
data.put("targetBottom", Profile.fromMgdlToUnits(tempTarget.low, ProfileFunctions.getSystemUnits()));
|
data.put("reason", tempTarget.reason);
|
||||||
data.put("targetTop", Profile.fromMgdlToUnits(tempTarget.high, ProfileFunctions.getSystemUnits()));
|
data.put("targetBottom", Profile.fromMgdlToUnits(tempTarget.low, ProfileFunctions.getSystemUnits()));
|
||||||
|
data.put("targetTop", Profile.fromMgdlToUnits(tempTarget.high, ProfileFunctions.getSystemUnits()));
|
||||||
|
data.put("units", ProfileFunctions.getSystemUnits());
|
||||||
|
}
|
||||||
data.put("created_at", DateUtil.toISOString(tempTarget.date));
|
data.put("created_at", DateUtil.toISOString(tempTarget.date));
|
||||||
data.put("units", ProfileFunctions.getSystemUnits());
|
|
||||||
data.put("enteredBy", MainApp.gs(R.string.app_name));
|
data.put("enteredBy", MainApp.gs(R.string.app_name));
|
||||||
uploadCareportalEntryToNS(data);
|
uploadCareportalEntryToNS(data);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
|
Loading…
Reference in a new issue