From 579c9dac7c4de41b36a4fed67494e0038d2196c7 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 11 Nov 2021 20:41:32 +0100 Subject: [PATCH] Glunovo rearrange --- .../androidaps/plugins/source/GlunovoPlugin.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlunovoPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlunovoPlugin.kt index d2b6900836..b541389895 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlunovoPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlunovoPlugin.kt @@ -94,6 +94,13 @@ class GlunovoPlugin @Inject constructor( val timestamp = cr.getLong(0) val value = cr.getDouble(1) //value in mmol/l... val curr = cr.getDouble(2) + + // bypass already processed + if (timestamp < sp.getLong(R.string.key_last_processed_glunovo_timestamp, 0L)) { + cr.moveToNext() + continue + } + if (timestamp > dateUtil.now() || timestamp == 0L) { aapsLogger.error(LTag.BGSOURCE, "Error in received data date/time $timestamp") cr.moveToNext() @@ -106,12 +113,6 @@ class GlunovoPlugin @Inject constructor( continue } - // bypass already processed - if (timestamp < sp.getLong(R.string.key_last_processed_glunovo_timestamp, 0L)) { - cr.moveToNext() - continue - } - if (curr != 0.0) glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( timestamp = timestamp, @@ -134,7 +135,7 @@ class GlunovoPlugin @Inject constructor( } cr.close() - if (glucoseValues.isNotEmpty()) + if (glucoseValues.isNotEmpty() || calibrations.isNotEmpty()) repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, calibrations, null)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Glunovo App", it)