Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions LoopFollow/Alarm/AlarmCondition/MissedReadingCondition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct MissedReadingCondition: AlarmCondition {
static let type: AlarmType = .missedReading
init() {}

func evaluate(alarm: Alarm, data: AlarmData, now _: Date) -> Bool {
func evaluate(alarm: Alarm, data: AlarmData, now : Date) -> Bool {
// ────────────────────────────────
// 0. sanity checks
// ────────────────────────────────
Expand All @@ -18,7 +18,7 @@ struct MissedReadingCondition: AlarmCondition {
// Skip if we have *no* readings
guard let last = data.bgReadings.last else { return false }

let secondsSinceLast = Date().timeIntervalSince(last.date)
let secondsSinceLast = now.timeIntervalSince(last.date)
return secondsSinceLast >= thresholdMinutes * 60
}
}
6 changes: 4 additions & 2 deletions LoopFollow/Alarm/AlarmManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ class AlarmManager {
continue
}

// If the alarm is based on bg values, and the value isnt recent, skip to next
if alarm.type.isBGBased, !isLatestReadingRecent {
// If an alarm is BG-based, it usually requires recent data.
// We make a specific exception for .missedReading, whose entire
// purpose is to fire when recent BG data is NOT recent.
if alarm.type.isBGBased, alarm.type != .missedReading, !isLatestReadingRecent {
continue
}

Expand Down