Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Apple Health read: round the heart rate before the plausibility check, as Android and JS do

Duarte Santose5a881ae1256
diff --git a/frontend/ios/App/WatchCore/Sources/WatchCore/HealthReadCore.swift b/frontend/ios/App/WatchCore/Sources/WatchCore/HealthReadCore.swift
index 833e74c15..d0d2edd3f 100644
--- a/frontend/ios/App/WatchCore/Sources/WatchCore/HealthReadCore.swift
+++ b/frontend/ios/App/WatchCore/Sources/WatchCore/HealthReadCore.swift
@@ -30,9 +30,10 @@ public enum HealthReadCore {
}
}
- /// The samples in [from, to] with a plausible rate, oldest first, as [[ms, bpm]].
+ /// The samples in [from, to] with a plausible rate, oldest first, as [[ms, bpm]]. The rate is
+ /// rounded first, as Health Connect's whole beats and lib/heart-rate.js have it: 250.4 is 250.
public static func samples(_ all: [HeartSample], from: Double, to: Double) -> [[Double]] {
- let kept = all.filter { $0.ms >= from && $0.ms <= to && bpmRange.contains($0.bpm) }
+ let kept = all.filter { $0.ms >= from && $0.ms <= to && bpmRange.contains($0.bpm.rounded()) }
.sorted { $0.ms < $1.ms }
.prefix(maxSamples)
return kept.map { [$0.ms.rounded(), $0.bpm.rounded()] }