|
|
@@ -98,6 +98,27 @@ import Testing
|
|
|
autosens: try JSONBridge.to(iobInputs.autosens)
|
|
|
)
|
|
|
|
|
|
+ // In suspendedPrior mode (first suspend/resume event is a Resume), JS incorrectly
|
|
|
+ // returns pre-resume temp basals in lastTemp because history.js line 566 uses
|
|
|
+ // tempHistory instead of splitHistory. Swift correctly handles this case.
|
|
|
+ if case let .success(jsRawJson) = iobResultJavascript,
|
|
|
+ let jsIobEntries = try? JSONBridge.iobResult(from: jsRawJson),
|
|
|
+ let jsLastTempDate = jsIobEntries.first?.lastTemp?.date
|
|
|
+ {
|
|
|
+ let suspendResumeEvents = iobInputs.history
|
|
|
+ .filter { $0.type == .pumpSuspend || $0.type == .pumpResume }
|
|
|
+ .sorted { $0.timestamp < $1.timestamp }
|
|
|
+ if let firstEvent = suspendResumeEvents.first,
|
|
|
+ firstEvent.type == .pumpResume
|
|
|
+ {
|
|
|
+ let firstResumeTime = UInt64(firstEvent.timestamp.timeIntervalSince1970 * 1000)
|
|
|
+ if jsLastTempDate < firstResumeTime {
|
|
|
+ print("Skipping, known issue with JS lastTemp in suspendedPrior mode")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
let comparison = JSONCompare.createComparison(
|
|
|
function: .iob,
|
|
|
swift: iobResultSwift,
|