Skip to content

Commit bc13d5d

Browse files
Consider Persistent High only if all the readings in the evaluated period are above the upper bound (not the average, as before)
1 parent fa18f52 commit bc13d5d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

nightguard/AlarmRule.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ class AlarmRule {
147147
if currentReading.value < persistentHighUpperBound.value {
148148

149149
// if all the previous readings (for the defined minutes are high, we'll consider it a persistent high)
150-
let lastReadingValues = bloodValues.lastXMinutes(persistentHighMinutes.value).map { Double($0.value) }
150+
let lastReadings = bloodValues.lastXMinutes(persistentHighMinutes.value)
151151

152152
// we should have at least a reading in 10 minutes for considering a persistent high
153-
if !lastReadingValues.isEmpty && (lastReadingValues.count >= (persistentHighMinutes.value / 10)) {
154-
if AlarmRule.isTooHigh(Float(lastReadingValues.average)) {
153+
if !lastReadings.isEmpty && (lastReadings.count >= (persistentHighMinutes.value / 10)) {
154+
if lastReadings.allSatisfy({ AlarmRule.isTooHigh($0.value) }) {
155155
return "Persistent High BG"
156156
} else {
157157
return nil

0 commit comments

Comments
 (0)