Bladeren bron

Filter out values above 3000

Jonas Björkert 3 jaren geleden
bovenliggende
commit
bea99870aa
1 gewijzigde bestanden met toevoegingen van 10 en 3 verwijderingen
  1. 10 3
      LoopFollow/Controllers/NightScout.swift

+ 10 - 3
LoopFollow/Controllers/NightScout.swift

@@ -330,13 +330,20 @@ extension MainViewController {
         }
         }
         
         
         // loop through the data so we can reverse the order to oldest first for the graph
         // loop through the data so we can reverse the order to oldest first for the graph
-        for i in 0..<data.count{
+        for i in 0..<data.count {
             let dateString = data[data.count - 1 - i].date
             let dateString = data[data.count - 1 - i].date
             if dateString >= dateTimeUtils.getTimeIntervalNHoursAgo(N: graphHours) {
             if dateString >= dateTimeUtils.getTimeIntervalNHoursAgo(N: graphHours) {
-                let reading = ShareGlucoseData(sgv: data[data.count - 1 - i].sgv, date: dateString, direction: data[data.count - 1 - i].direction)
+                let sgvValue = data[data.count - 1 - i].sgv
+                
+                // Skip the current iteration if the sgv value is over 3000
+                // First time a user starts a G7, they get a value of 4000
+                if sgvValue > 3000 {
+                    continue
+                }
+                
+                let reading = ShareGlucoseData(sgv: sgvValue, date: dateString, direction: data[data.count - 1 - i].direction)
                 bgData.append(reading)
                 bgData.append(reading)
             }
             }
-            
         }
         }
 
 
         viewUpdateNSBG(sourceName: sourceName)
         viewUpdateNSBG(sourceName: sourceName)