Skip to content

Commit

Permalink
Merge pull request loopandlearn#207 from loopandlearn/g7-4000
Browse files Browse the repository at this point in the history
Filter out values above 600
  • Loading branch information
marionbarker authored Jul 31, 2023
2 parents 1136c55 + f0ef7f7 commit 831250d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions LoopFollow/Controllers/NightScout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,20 @@ extension MainViewController {
}

// 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
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 600
// First time a user starts a G7, they get a value of 4000
if sgvValue > 600 {
continue
}

let reading = ShareGlucoseData(sgv: sgvValue, date: dateString, direction: data[data.count - 1 - i].direction)
bgData.append(reading)
}

}

viewUpdateNSBG(sourceName: sourceName)
Expand Down Expand Up @@ -574,8 +581,12 @@ extension MainViewController {
var i = 0
while i <= toLoad {
if i < prediction.count {
let prediction = ShareGlucoseData(sgv: Int(round(prediction[i])), date: predictionTime, direction: "flat")
predictionData.append(prediction)
let sgvValue = Int(round(prediction[i]))
// Skip values higher than 600
if sgvValue <= 600 {
let prediction = ShareGlucoseData(sgv: sgvValue, date: predictionTime, direction: "flat")
predictionData.append(prediction)
}
predictionTime += 300
}
i += 1
Expand Down

0 comments on commit 831250d

Please sign in to comment.