From 9e2ce1cc271ac1f69862df28624c2410ed056c7e Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 9 Mar 2021 22:41:57 +0100 Subject: [PATCH] Fix uel after last merge (Mainly Careportal entries form NS) --- .../androidaps/dialogs/CareDialog.kt | 2 +- .../general/nsclient/NSClientPlugin.java | 6 ++-- .../utils/extensions/UserEntryExt.kt | 2 ++ core/src/main/res/values/strings.xml | 2 ++ .../4.json | 30 ++++--------------- .../androidaps/database/entities/UserEntry.kt | 2 ++ 6 files changed, 16 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt index 5440c227d0..3408e3e43f 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -202,7 +202,7 @@ class CareDialog : DialogFragmentWithDate() { therapyEvent.glucoseType = meterType therapyEvent.glucose = binding.bg.value valuesWithUnit.add(ValueWithUnit(binding.bg.value.toDouble(), profileFunction.getUnits())) - valuesWithUnit.add(ValueWithUnit(meterType, Units.CPEvent)) + valuesWithUnit.add(ValueWithUnit(meterType.text, Units.CPEvent)) } if (options == EventType.NOTE || options == EventType.EXERCISE) { actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_duration_label) + ": " + resourceHelper.gs(R.string.format_mins, binding.duration.value.toInt())) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java index 29c76b9277..d59afdbd9a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java @@ -433,7 +433,7 @@ public class NSClientPlugin extends PluginBase { // room Therapy Event TherapyEvent therapyEvent = therapyEventFromNsIdForInvalidating(_id); disposable.add(repository.runTransactionForResult(new SyncTherapyEventTransaction(therapyEvent)).subscribe( - result -> result.getInvalidated().forEach(record -> uel.log("CAREPORTAL EVENT DELETED FROM NS", record.getType().getText(), 0.0, 0.0, 0, 0)), + result -> result.getInvalidated().forEach(record -> uel.log(Action.CAREPORTAL_DELETED_FROM_NS, record.getNote() , new ValueWithUnit(record.getTimestamp(), Units.Timestamp), new ValueWithUnit(record.getType().getText(), Units.CPEvent), new ValueWithUnit(record.getGlucose(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration()/60000, Units.M))), error -> aapsLogger.error(LTag.DATABASE, "Error while removing therapy event", error))); // new DB model EventNsTreatment evtTreatment = new EventNsTreatment(EventNsTreatment.Companion.getREMOVE(), json); @@ -493,8 +493,8 @@ public class NSClientPlugin extends PluginBase { disposable.add(repository.runTransactionForResult(new SyncTherapyEventTransaction(therapyEvent)) .subscribe( result -> { - result.getInserted().forEach(record -> uel.log("CAREPORTAL EVENT NS", record.getType().getText(), 0.0, 0.0, 0, 0)); - result.getInvalidated().forEach(record -> uel.log("CAREPORTAL EVENT DELETED FROM NS", record.getType().getText(), 0.0, 0.0, 0, 0)); + result.getInserted().forEach(record -> uel.log(Action.CAREPORTAL_FROM_NS, record.getNote() , new ValueWithUnit(record.getTimestamp(), Units.Timestamp), new ValueWithUnit(record.getType().getText(), Units.CPEvent))); + result.getInvalidated().forEach(record -> uel.log(Action.CAREPORTAL_DELETED_FROM_NS, record.getNote() , new ValueWithUnit(record.getTimestamp(), Units.Timestamp), new ValueWithUnit(record.getType().getText(), Units.CPEvent))); }, error -> aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", error))); } else { diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt index c9de6b11f3..83c188382d 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt @@ -101,6 +101,8 @@ fun Action.stringId(): Int { Action.TT_DELETED_FROM_NS -> R.string.uel_tt_deleted_from_ns Action.TT_FROM_NS -> R.string.uel_tt_from_ns Action.TT_CANCELED_FROM_NS -> R.string.uel_tt_canceleted_from_ns + Action.CAREPORTAL_DELETED_FROM_NS -> R.string.uel_careportal_deleted_from_ns + Action.CAREPORTAL_FROM_NS -> R.string.uel_careportal_from_ns Action.EXPORT_CSV -> R.string.uel_export_csv else -> R.string.uel_unknown } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 45610d7af7..3a7118d561 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -485,6 +485,8 @@ SMS SMS SMS TT TT DELETED FROM NS + CAREPORTAL DELETED FROM NS + CAREPORTAL FROM NS TT FROM NS TT CANCELED FROM NS EXPORT USER ENTRIES diff --git a/database/schemas/info.nightscout.androidaps.database.AppDatabase/4.json b/database/schemas/info.nightscout.androidaps.database.AppDatabase/4.json index bbb359e373..2271d3a4c9 100644 --- a/database/schemas/info.nightscout.androidaps.database.AppDatabase/4.json +++ b/database/schemas/info.nightscout.androidaps.database.AppDatabase/4.json @@ -2,7 +2,7 @@ "formatVersion": 1, "database": { "version": 4, - "identityHash": "e8b8785efbd1699431eef90a5b441ed3", + "identityHash": "c6cb19c6cfa6d0fb738b3f58818172ff", "entities": [ { "tableName": "apsResults", @@ -2699,7 +2699,7 @@ }, { "tableName": "userEntry", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `d1` REAL NOT NULL, `d2` REAL NOT NULL, `i1` INTEGER NOT NULL, `i2` INTEGER NOT NULL)", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `values` TEXT NOT NULL)", "fields": [ { "fieldPath": "id", @@ -2732,27 +2732,9 @@ "notNull": true }, { - "fieldPath": "d1", - "columnName": "d1", - "affinity": "REAL", - "notNull": true - }, - { - "fieldPath": "d2", - "columnName": "d2", - "affinity": "REAL", - "notNull": true - }, - { - "fieldPath": "i1", - "columnName": "i1", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "i2", - "columnName": "i2", - "affinity": "INTEGER", + "fieldPath": "values", + "columnName": "values", + "affinity": "TEXT", "notNull": true } ], @@ -2769,7 +2751,7 @@ "views": [], "setupQueries": [ "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, 'e8b8785efbd1699431eef90a5b441ed3')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'c6cb19c6cfa6d0fb738b3f58818172ff')" ] } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt b/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt index 4c7bfcb0fe..002b43bd8e 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt @@ -113,6 +113,8 @@ data class UserEntry( @SerializedName("SMS_SMS") SMS_SMS (ColorGroup.Aaps), @SerializedName("SMS_TT") SMS_TT (ColorGroup.TT), @SerializedName("TT_DELETED_FROM_NS") TT_DELETED_FROM_NS (ColorGroup.TT), + @SerializedName("CAREPORTAL_DELETED_FROM_NS") CAREPORTAL_DELETED_FROM_NS (ColorGroup.Careportal), + @SerializedName("CAREPORTAL_FROM_NS") CAREPORTAL_FROM_NS (ColorGroup.Careportal), @SerializedName("TT_FROM_NS") TT_FROM_NS (ColorGroup.TT), @SerializedName("TT_CANCELED_FROM_NS") TT_CANCELED_FROM_NS (ColorGroup.TT), @SerializedName("EXPORT_CSV") EXPORT_CSV (ColorGroup.Aaps),