G6: ignore too old values
This commit is contained in:
parent
edc963da25
commit
8c28dd0f52
1 changed files with 4 additions and 0 deletions
|
@ -125,6 +125,7 @@ class DexcomPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val now = dateUtil.now()
|
||||||
val glucoseValuesBundle = bundle.getBundle("glucoseValues")
|
val glucoseValuesBundle = bundle.getBundle("glucoseValues")
|
||||||
?: return Result.failure(workDataOf("Error" to "missing glucoseValues"))
|
?: return Result.failure(workDataOf("Error" to "missing glucoseValues"))
|
||||||
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>()
|
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>()
|
||||||
|
@ -135,6 +136,9 @@ class DexcomPlugin @Inject constructor(
|
||||||
var valid = true
|
var valid = true
|
||||||
if (sourceSensor == GlucoseValue.SourceSensor.DEXCOM_G5_NATIVE)
|
if (sourceSensor == GlucoseValue.SourceSensor.DEXCOM_G5_NATIVE)
|
||||||
calibrations.forEach { calibration -> if (calibration.timestamp == timestamp) valid = false }
|
calibrations.forEach { calibration -> if (calibration.timestamp == timestamp) valid = false }
|
||||||
|
// G6 is sending one 24h old changed value causing recalculation. Ignore
|
||||||
|
if (sourceSensor == GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE)
|
||||||
|
if ((now - timestamp) > T.hours(20).msecs()) valid = false
|
||||||
if (valid)
|
if (valid)
|
||||||
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue(
|
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue(
|
||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
|
|
Loading…
Reference in a new issue