fix carbs entry notes
field
This commit is contained in:
parent
f0a37d64f3
commit
1588df7ffe
|
@ -116,7 +116,8 @@ class DetailedBolusInfo {
|
||||||
Carbs(
|
Carbs(
|
||||||
timestamp = carbsTimestamp ?: timestamp,
|
timestamp = carbsTimestamp ?: timestamp,
|
||||||
amount = carbs,
|
amount = carbs,
|
||||||
duration = carbsDuration
|
duration = carbsDuration,
|
||||||
|
notes = notes,
|
||||||
)
|
)
|
||||||
else null
|
else null
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ fun Carbs.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject =
|
||||||
JSONObject()
|
JSONObject()
|
||||||
.put("eventType", if (amount < 12) TherapyEvent.Type.CARBS_CORRECTION.text else TherapyEvent.Type.MEAL_BOLUS.text)
|
.put("eventType", if (amount < 12) TherapyEvent.Type.CARBS_CORRECTION.text else TherapyEvent.Type.MEAL_BOLUS.text)
|
||||||
.put("carbs", amount)
|
.put("carbs", amount)
|
||||||
|
.put("notes", notes)
|
||||||
.put("created_at", dateUtil.toISOString(timestamp))
|
.put("created_at", dateUtil.toISOString(timestamp))
|
||||||
.put("isValid", isValid)
|
.put("isValid", isValid)
|
||||||
.put("date", timestamp).also {
|
.put("date", timestamp).also {
|
||||||
|
@ -29,6 +30,7 @@ fun carbsFromNsIdForInvalidating(nsId: String): Carbs =
|
||||||
JSONObject()
|
JSONObject()
|
||||||
.put("mills", 1)
|
.put("mills", 1)
|
||||||
.put("carbs", -1.0)
|
.put("carbs", -1.0)
|
||||||
|
.put("notes", null)
|
||||||
.put("_id", nsId)
|
.put("_id", nsId)
|
||||||
.put("isValid", false)
|
.put("isValid", false)
|
||||||
)!!
|
)!!
|
||||||
|
@ -37,6 +39,7 @@ fun carbsFromJson(jsonObject: JSONObject): Carbs? {
|
||||||
val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null
|
val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null
|
||||||
val duration = JsonHelper.safeGetLong(jsonObject, "duration")
|
val duration = JsonHelper.safeGetLong(jsonObject, "duration")
|
||||||
val amount = JsonHelper.safeGetDoubleAllowNull(jsonObject, "carbs") ?: return null
|
val amount = JsonHelper.safeGetDoubleAllowNull(jsonObject, "carbs") ?: return null
|
||||||
|
val notes = JsonHelper.safeGetStringAllowNull(jsonObject, "notes", null)
|
||||||
val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true)
|
val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true)
|
||||||
val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) ?: return null
|
val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) ?: return null
|
||||||
val pumpId = JsonHelper.safeGetLongAllowNull(jsonObject, "pumpId", null)
|
val pumpId = JsonHelper.safeGetLongAllowNull(jsonObject, "pumpId", null)
|
||||||
|
@ -50,6 +53,7 @@ fun carbsFromJson(jsonObject: JSONObject): Carbs? {
|
||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
duration = duration,
|
duration = duration,
|
||||||
amount = amount,
|
amount = amount,
|
||||||
|
notes = notes,
|
||||||
isValid = isValid
|
isValid = isValid
|
||||||
).also {
|
).also {
|
||||||
it.interfaceIDs.nightscoutId = id
|
it.interfaceIDs.nightscoutId = id
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"formatVersion": 1,
|
"formatVersion": 1,
|
||||||
"database": {
|
"database": {
|
||||||
"version": 21,
|
"version": 21,
|
||||||
"identityHash": "e3558dc3bb3136c37dba4f90c97e8bdd",
|
"identityHash": "8e5c513355bfdf0d24e72eedc263f0c3",
|
||||||
"entities": [
|
"entities": [
|
||||||
{
|
{
|
||||||
"tableName": "apsResults",
|
"tableName": "apsResults",
|
||||||
|
@ -733,7 +733,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"tableName": "carbs",
|
"tableName": "carbs",
|
||||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `duration` INTEGER NOT NULL, `amount` REAL NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `temporaryId` INTEGER, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `carbs`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `duration` INTEGER NOT NULL, `amount` REAL NOT NULL, `notes` TEXT, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `temporaryId` INTEGER, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `carbs`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"fieldPath": "id",
|
"fieldPath": "id",
|
||||||
|
@ -789,6 +789,12 @@
|
||||||
"affinity": "REAL",
|
"affinity": "REAL",
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "notes",
|
||||||
|
"columnName": "notes",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldPath": "interfaceIDs_backing.nightscoutSystemId",
|
"fieldPath": "interfaceIDs_backing.nightscoutSystemId",
|
||||||
"columnName": "nightscoutSystemId",
|
"columnName": "nightscoutSystemId",
|
||||||
|
@ -3587,7 +3593,7 @@
|
||||||
"views": [],
|
"views": [],
|
||||||
"setupQueries": [
|
"setupQueries": [
|
||||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'e3558dc3bb3136c37dba4f90c97e8bdd')"
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '8e5c513355bfdf0d24e72eedc263f0c3')"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -35,7 +35,8 @@ data class Carbs(
|
||||||
override var timestamp: Long,
|
override var timestamp: Long,
|
||||||
override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(),
|
override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(),
|
||||||
override var duration: Long, // in milliseconds
|
override var duration: Long, // in milliseconds
|
||||||
var amount: Double
|
var amount: Double,
|
||||||
|
var notes: String? = null
|
||||||
) : TraceableDBEntry, DBEntryWithTimeAndDuration {
|
) : TraceableDBEntry, DBEntryWithTimeAndDuration {
|
||||||
|
|
||||||
private fun contentEqualsTo(other: Carbs): Boolean =
|
private fun contentEqualsTo(other: Carbs): Boolean =
|
||||||
|
@ -43,6 +44,7 @@ data class Carbs(
|
||||||
timestamp == other.timestamp &&
|
timestamp == other.timestamp &&
|
||||||
utcOffset == other.utcOffset &&
|
utcOffset == other.utcOffset &&
|
||||||
amount == other.amount &&
|
amount == other.amount &&
|
||||||
|
notes == other.notes &&
|
||||||
duration == other.duration
|
duration == other.duration
|
||||||
|
|
||||||
fun onlyNsIdAdded(previous: Carbs): Boolean =
|
fun onlyNsIdAdded(previous: Carbs): Boolean =
|
||||||
|
|
|
@ -14,11 +14,13 @@ class InsertOrUpdateCarbsTransaction(
|
||||||
timestamp: Long,
|
timestamp: Long,
|
||||||
amount: Double,
|
amount: Double,
|
||||||
duration: Long,
|
duration: Long,
|
||||||
|
notes: String,
|
||||||
interfaceIDs_backing: InterfaceIDs? = null
|
interfaceIDs_backing: InterfaceIDs? = null
|
||||||
) : this(Carbs(
|
) : this(Carbs(
|
||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
amount = amount,
|
amount = amount,
|
||||||
duration = duration,
|
duration = duration,
|
||||||
|
notes = notes,
|
||||||
interfaceIDs_backing = interfaceIDs_backing
|
interfaceIDs_backing = interfaceIDs_backing
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue