Skip to content

Commit

Permalink
Clean up (#909)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-b-m authored Oct 22, 2024
1 parent 8cb6877 commit 608a38c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 38 deletions.
21 changes: 0 additions & 21 deletions Core_Data.xcdatamodeld/Core_Data.xcdatamodel/contents
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,6 @@
<attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="name" optional="YES" attributeType="String"/>
</entity>
<entity name="BGaverages" representedClassName="BGaverages" syncable="YES" codeGenerationType="class">
<attribute name="average" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="average_1" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="average_7" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="average_30" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
</entity>
<entity name="BGmedian" representedClassName="BGmedian" syncable="YES" codeGenerationType="class">
<attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="median" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="median_1" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="median_7" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="median_30" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
</entity>
<entity name="Carbohydrates" representedClassName="Carbohydrates" syncable="YES" codeGenerationType="class">
<attribute name="carbs" optional="YES" attributeType="Decimal" defaultValueString="0"/>
<attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
Expand All @@ -29,13 +15,6 @@
<attribute name="enteredBy" optional="YES" attributeType="String"/>
<attribute name="fat" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
</entity>
<entity name="HbA1c" representedClassName="HbA1c" syncable="YES" codeGenerationType="class">
<attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="hba1c" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="hba1c_1" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="hba1c_7" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="hba1c_30" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
</entity>
<entity name="Identifier" representedClassName="Identifier" syncable="YES" codeGenerationType="class">
<attribute name="id" optional="YES" attributeType="String"/>
</entity>
Expand Down
26 changes: 13 additions & 13 deletions FreeAPS/Sources/APS/APSManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -885,8 +885,8 @@ final class BaseAPSManager: APSManager, Injectable {
let glucose = array
let justGlucoseArray = glucose.compactMap({ each in Int(each.glucose as Int16) })
let totalReadings = justGlucoseArray.count
let highLimit = settingsManager.settings.high
let lowLimit = settingsManager.settings.low
let highLimit = settings.high
let lowLimit = settings.low
let hyperArray = glucose.filter({ $0.glucose >= Int(highLimit) })
let hyperReadings = hyperArray.compactMap({ each in each.glucose as Int16 }).count
let hyperPercentage = Double(hyperReadings) / Double(totalReadings) * 100
Expand Down Expand Up @@ -942,7 +942,7 @@ final class BaseAPSManager: APSManager, Injectable {
cv = sd / Double(glucoseAverage) * 100
}
let conversionFactor = 0.0555
let units = settingsManager.settings.units
let units = settings.units

var output: (ifcc: Double, ngsp: Double, average: Double, median: Double, sd: Double, cv: Double, readings: Double)
output = (
Expand Down Expand Up @@ -1015,8 +1015,8 @@ final class BaseAPSManager: APSManager, Injectable {
return
}

if settingsManager.settings.uploadStats {
let units = settingsManager.settings.units
if settings.uploadStats {
let units = settings.units
let preferences = settingsManager.preferences

// Carbs
Expand Down Expand Up @@ -1055,7 +1055,7 @@ final class BaseAPSManager: APSManager, Injectable {
let branch = branch()
let copyrightNotice_ = Bundle.main.infoDictionary?["NSHumanReadableCopyright"] as? String ?? ""
let pump_ = pumpManager?.localizedTitle ?? ""
let cgm = settingsManager.settings.cgm
let cgm = settings.cgm
let file = OpenAPS.Monitor.statistics
var iPa: Decimal = 75
if preferences.useCustomPeakTime {
Expand Down Expand Up @@ -1091,7 +1091,7 @@ final class BaseAPSManager: APSManager, Injectable {
total: roundDecimal(Decimal(totalDaysGlucose.median), 1)
)

let overrideHbA1cUnit = settingsManager.settings.overrideHbA1cUnit
let overrideHbA1cUnit = settings.overrideHbA1cUnit

let hbs = Durations(
day: ((units == .mmolL && !overrideHbA1cUnit) || (units == .mgdL && overrideHbA1cUnit)) ?
Expand Down Expand Up @@ -1139,10 +1139,10 @@ final class BaseAPSManager: APSManager, Injectable {
total: Decimal(totalDays_.normal_)
)
let range = Threshold(
low: units == .mmolL ? roundDecimal(settingsManager.settings.low.asMmolL, 1) :
roundDecimal(settingsManager.settings.low, 0),
high: units == .mmolL ? roundDecimal(settingsManager.settings.high.asMmolL, 1) :
roundDecimal(settingsManager.settings.high, 0)
low: units == .mmolL ? roundDecimal(settings.low.asMmolL, 1) :
roundDecimal(settings.low, 0),
high: units == .mmolL ? roundDecimal(settings.high.asMmolL, 1) :
roundDecimal(settings.high, 0)
)
let TimeInRange = TIRs(
TIR: tir,
Expand Down Expand Up @@ -1250,8 +1250,8 @@ final class BaseAPSManager: APSManager, Injectable {
Variance: variance
),
id: getIdentifier(),
dob: settingsManager.settings.birthDate,
sex: settingsManager.settings.sexSetting
dob: settings.birthDate,
sex: settings.sexSetting
)
storage.save(dailystat, as: file)
nightscout.uploadStatistics(dailystat: dailystat)
Expand Down
6 changes: 2 additions & 4 deletions FreeAPS/Sources/Helpers/CoreDataStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CoreDataStack: ObservableObject {

container.loadPersistentStores(completionHandler: { _, error in
guard let error = error as NSError? else { return }
fatalError("Unresolved error: \(error), \(error.userInfo)")
debug(.apsManager, "Unresolved error: \(error), \(error.userInfo)")
})

return container
Expand All @@ -25,10 +25,8 @@ class CoreDataStack: ObservableObject {
do {
try context.save()
} catch {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
let nserror = error as NSError
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
debug(.apsManager, "Unresolved error \(nserror), \(nserror.userInfo)")
}
}
}
Expand Down

0 comments on commit 608a38c

Please sign in to comment.