|
@@ -667,13 +667,10 @@ final class BaseAPSManager: APSManager, Injectable {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
nightscout.uploadStatus()
|
|
nightscout.uploadStatus()
|
|
|
-
|
|
|
|
|
// Update the TDD value
|
|
// Update the TDD value
|
|
|
tdd(enacted_: enacted)
|
|
tdd(enacted_: enacted)
|
|
|
- // Update statistics. Only run if enabled in preferences
|
|
|
|
|
- // if settingsManager.settings.displayStatistics {
|
|
|
|
|
|
|
+ // Update statistics
|
|
|
statistics()
|
|
statistics()
|
|
|
- // }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -771,7 +768,7 @@ final class BaseAPSManager: APSManager, Injectable {
|
|
|
testIfEmpty = testFile.count
|
|
testIfEmpty = testFile.count
|
|
|
}
|
|
}
|
|
|
let updateThisOften = Int(settingsManager.preferences.updateInterval)
|
|
let updateThisOften = Int(settingsManager.preferences.updateInterval)
|
|
|
- // Only run every 30 minutes of according to setting.
|
|
|
|
|
|
|
+ // Only run every 30 minutes or according to setting.
|
|
|
if testIfEmpty != 0 {
|
|
if testIfEmpty != 0 {
|
|
|
guard testFile[0].created_at.addingTimeInterval(updateThisOften.minutes.timeInterval) < Date()
|
|
guard testFile[0].created_at.addingTimeInterval(updateThisOften.minutes.timeInterval) < Date()
|
|
|
else {
|
|
else {
|
|
@@ -983,13 +980,13 @@ final class BaseAPSManager: APSManager, Injectable {
|
|
|
|
|
|
|
|
try? glucose = coredataContext.fetch(requestGFS)
|
|
try? glucose = coredataContext.fetch(requestGFS)
|
|
|
|
|
|
|
|
- firstElementTime = glucose.first?.date ?? Date()
|
|
|
|
|
- lastElementTime = glucose.last?.date ?? Date()
|
|
|
|
|
|
|
+ // Time In Range (%) and Average Glucose. This will be refactored later after some testing.
|
|
|
|
|
+ let endIndex = glucose.count - 1
|
|
|
|
|
|
|
|
- currentIndexTime = firstElementTime
|
|
|
|
|
|
|
+ firstElementTime = glucose[0].date ?? Date()
|
|
|
|
|
+ lastElementTime = glucose[endIndex].date ?? Date()
|
|
|
|
|
|
|
|
- // Time In Range (%) and Average Glucose (24 hours). This will be refactored later after some testing.
|
|
|
|
|
- let endIndex = glucose.count - 1
|
|
|
|
|
|
|
+ currentIndexTime = firstElementTime
|
|
|
|
|
|
|
|
numberOfDays = (firstElementTime - lastElementTime).timeInterval / 8.64E4
|
|
numberOfDays = (firstElementTime - lastElementTime).timeInterval / 8.64E4
|
|
|
|
|
|
|
@@ -1003,23 +1000,23 @@ final class BaseAPSManager: APSManager, Injectable {
|
|
|
bgArray.append(Double(glucose[j].glucose) * Double(conversionFactor))
|
|
bgArray.append(Double(glucose[j].glucose) * Double(conversionFactor))
|
|
|
bgArrayForTIR.append((Double(glucose[j].glucose), glucose[j].date!))
|
|
bgArrayForTIR.append((Double(glucose[j].glucose), glucose[j].date!))
|
|
|
nr_bgs += 1
|
|
nr_bgs += 1
|
|
|
- if (firstElementTime - currentIndexTime).timeInterval / 60 <= 8.64E4 { // 1 day
|
|
|
|
|
|
|
+ if (firstElementTime - currentIndexTime).timeInterval <= 8.64E4 { // 1 day
|
|
|
bg_1 = bg / nr_bgs
|
|
bg_1 = bg / nr_bgs
|
|
|
bgArray_1 = bgArrayForTIR
|
|
bgArray_1 = bgArrayForTIR
|
|
|
bgArray_1_ = bgArray
|
|
bgArray_1_ = bgArray
|
|
|
nr1 = nr_bgs
|
|
nr1 = nr_bgs
|
|
|
}
|
|
}
|
|
|
- if (firstElementTime - currentIndexTime).timeInterval / 60 <= 6.048E5 { // 7 days
|
|
|
|
|
|
|
+ if (firstElementTime - currentIndexTime).timeInterval <= 6.048E5 { // 7 days
|
|
|
bg_7 = bg / nr_bgs
|
|
bg_7 = bg / nr_bgs
|
|
|
bgArray_7 = bgArrayForTIR
|
|
bgArray_7 = bgArrayForTIR
|
|
|
bgArray_7_ = bgArray
|
|
bgArray_7_ = bgArray
|
|
|
}
|
|
}
|
|
|
- if (firstElementTime - currentIndexTime).timeInterval / 60 <= 2.592E6 { // 30 days
|
|
|
|
|
|
|
+ if (firstElementTime - currentIndexTime).timeInterval <= 2.592E6 { // 30 days
|
|
|
bg_30 = bg / nr_bgs
|
|
bg_30 = bg / nr_bgs
|
|
|
bgArray_30 = bgArrayForTIR
|
|
bgArray_30 = bgArrayForTIR
|
|
|
bgArray_30_ = bgArray
|
|
bgArray_30_ = bgArray
|
|
|
}
|
|
}
|
|
|
- if (firstElementTime - currentIndexTime).timeInterval / 60 <= 7.776E7 { // 30 days
|
|
|
|
|
|
|
+ if (firstElementTime - currentIndexTime).timeInterval <= 7.776E7 { // 30 days
|
|
|
bg_90 = bg / nr_bgs
|
|
bg_90 = bg / nr_bgs
|
|
|
bgArray_90 = bgArrayForTIR
|
|
bgArray_90 = bgArrayForTIR
|
|
|
bgArray_90_ = bgArray
|
|
bgArray_90_ = bgArray
|