Glunovo rearrange

This commit is contained in:
Milos Kozak 2021-11-11 20:41:32 +01:00
parent 774beb2cb3
commit 579c9dac7c

View file

@ -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)