Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
krugerk committed Nov 27, 2024
1 parent 73fbba8 commit 5dba383
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 1 addition & 3 deletions BeeKit/GoalExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ extension Goal {
if self.autodata == "ifttt" { return "IFTTT" }
if self.autodata == "api" { return "API" }
if self.autodata == "apple" {
let metric = HealthKitConfig.metrics.first(where: { (metric) -> Bool in
metric.databaseString == self.healthKitMetric
})
let metric = HealthKitConfig.metrics.first(where: { $0.databaseString == self.healthKitMetric })
return self.healthKitMetric == nil ? "Apple" : metric?.humanText
}
if let autodata = self.autodata, autodata.count > 0 { return autodata.capitalized }
Expand Down
12 changes: 6 additions & 6 deletions BeeKit/Managers/HealthStoreManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ public actor HealthStoreManager {

for metricName in metricNames {
if monitors[metricName] == nil {
guard let metric = HealthKitConfig.metrics.first(where: { (metric) -> Bool in
metric.databaseString == metricName
}) else {
guard
let metric = HealthKitConfig.metrics.first(where: { $0.databaseString == metricName })
else {
logger.error("No metric found for \(metricName, privacy: .public)")
continue
}
Expand Down Expand Up @@ -195,9 +195,9 @@ public actor HealthStoreManager {
}

private func updateWithRecentData(goal: Goal, days: Int) async throws {
guard let metric = HealthKitConfig.metrics.first(where: { (metric) -> Bool in
metric.databaseString == goal.healthKitMetric
}) else {
guard
let metric = HealthKitConfig.metrics.first(where: { $0.databaseString == goal.healthKitMetric })
else {
throw HealthKitError("No metric found for goal \(goal.slug) with metric \(goal.healthKitMetric ?? "nil")")
}
let newDataPoints = try await metric.recentDataPoints(days: days, deadline: goal.deadline, healthStore: healthStore)
Expand Down

0 comments on commit 5dba383

Please sign in to comment.