Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
krugerk committed Dec 18, 2024
1 parent c8f97d6 commit 4eea411
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions BeeKit/HeathKit/HealthKitConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public enum HealthKitConfig {
QuantityHealthKitMetric(humanText: "Water", databaseString: "water", category: .Nutrition, hkQuantityTypeIdentifier: .dietaryWater),

// Self care
ToothbrushingHealthKitMetric.make(),
ToothbrushingSessionsHealthKitMetric.make(),
ToothbrushingDailyMinutesHealthKitMetric.make(),
ToothbrushingDailySessionsHealthKitMetric.make(),

// Sleep
TimeInBedHealthKitMetric(humanText: "Time in bed", databaseString: "timeInBed", category: .Sleep),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Foundation
import HealthKit

/// tracks toothbrushing, in number of seconds per day (daystamp)
class ToothbrushingHealthKitMetric: CategoryHealthKitMetric {
private static let healthkitMetric = ["toothbrushing", "seconds-per-day"].joined(separator: "|")
/// tracks toothbrushing, in number of (decimal) minutes per day (daystamp)
class ToothbrushingDailyMinutesHealthKitMetric: CategoryHealthKitMetric {
private static let healthkitMetric = ["toothbrushing", "minutes-per-day"].joined(separator: "|")

private init(humanText: String,
databaseString: String,
Expand All @@ -18,7 +18,7 @@ class ToothbrushingHealthKitMetric: CategoryHealthKitMetric {
HKUnit.second()
}

static func make() -> ToothbrushingHealthKitMetric {
static func make() -> ToothbrushingDailyMinutesHealthKitMetric {
.init(humanText: "Teethbrushing (in seconds per day)",
databaseString: healthkitMetric,
category: HealthKitCategory.SelfCare)
Expand All @@ -29,7 +29,7 @@ class ToothbrushingHealthKitMetric: CategoryHealthKitMetric {
.map {
NewDataPoint(requestid: $0.requestid,
daystamp: $0.daystamp,
value: $0.value,
value: NSNumber(value: $0.value.doubleValue / 60),
comment: "Auto-entered via Apple Health (\(Self.healthkitMetric))")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Foundation
import HealthKit

/// tracks toothbrushing, in number of sessions per day (daystamp)
class ToothbrushingSessionsHealthKitMetric: CategoryHealthKitMetric {
class ToothbrushingDailySessionsHealthKitMetric: CategoryHealthKitMetric {
private static let healthkitMetric = ["toothbrushing", "sessions-per-day"].joined(separator: "|")

private init(humanText: String,
Expand All @@ -20,7 +20,7 @@ class ToothbrushingSessionsHealthKitMetric: CategoryHealthKitMetric {
.count()
}

static func make() -> ToothbrushingSessionsHealthKitMetric {
static func make() -> ToothbrushingDailySessionsHealthKitMetric {
.init(humanText: "Teethbrushing (in sessions per day)",
databaseString: healthkitMetric,
category: HealthKitCategory.SelfCare)
Expand Down
16 changes: 8 additions & 8 deletions BeeSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
9B1DCA5B2D10EA76006A64D9 /* ToothbrushingHealthKitMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B1DCA5A2D10EA76006A64D9 /* ToothbrushingHealthKitMetric.swift */; };
9B7D44662D12C304003B62B1 /* ToothbrushingSessionsHealthKitMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B7D44652D12C304003B62B1 /* ToothbrushingSessionsHealthKitMetric.swift */; };
9B1DCA5B2D10EA76006A64D9 /* ToothbrushingDailyMinutesHealthKitMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B1DCA5A2D10EA76006A64D9 /* ToothbrushingDailyMinutesHealthKitMetric.swift */; };
9B7D44662D12C304003B62B1 /* ToothbrushingDailySessionsHealthKitMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B7D44652D12C304003B62B1 /* ToothbrushingDailySessionsHealthKitMetric.swift */; };
9B8CA57D24B120CA009C86C2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9B8CA57C24B120CA009C86C2 /* LaunchScreen.storyboard */; };
A10D4E931B07948500A72D29 /* DatapointsTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10D4E921B07948500A72D29 /* DatapointsTableView.swift */; };
A10DC2DF207BFCBA00FB7B3A /* RemoveHKMetricViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10DC2DE207BFCBA00FB7B3A /* RemoveHKMetricViewController.swift */; };
Expand Down Expand Up @@ -219,8 +219,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
9B1DCA5A2D10EA76006A64D9 /* ToothbrushingHealthKitMetric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToothbrushingHealthKitMetric.swift; sourceTree = "<group>"; };
9B7D44652D12C304003B62B1 /* ToothbrushingSessionsHealthKitMetric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToothbrushingSessionsHealthKitMetric.swift; sourceTree = "<group>"; };
9B1DCA5A2D10EA76006A64D9 /* ToothbrushingDailyMinutesHealthKitMetric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToothbrushingDailyMinutesHealthKitMetric.swift; sourceTree = "<group>"; };
9B7D44652D12C304003B62B1 /* ToothbrushingDailySessionsHealthKitMetric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToothbrushingDailySessionsHealthKitMetric.swift; sourceTree = "<group>"; };
9B8CA57C24B120CA009C86C2 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
A10D4E921B07948500A72D29 /* DatapointsTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatapointsTableView.swift; sourceTree = "<group>"; };
A10DC2DE207BFCBA00FB7B3A /* RemoveHKMetricViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoveHKMetricViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -416,8 +416,8 @@
9B7D44642D12C2F3003B62B1 /* Toothbrushing */ = {
isa = PBXGroup;
children = (
9B7D44652D12C304003B62B1 /* ToothbrushingSessionsHealthKitMetric.swift */,
9B1DCA5A2D10EA76006A64D9 /* ToothbrushingHealthKitMetric.swift */,
9B7D44652D12C304003B62B1 /* ToothbrushingDailySessionsHealthKitMetric.swift */,
9B1DCA5A2D10EA76006A64D9 /* ToothbrushingDailyMinutesHealthKitMetric.swift */,
);
path = Toothbrushing;
sourceTree = "<group>";
Expand Down Expand Up @@ -1087,7 +1087,7 @@
E45470282B60E24500EE648B /* Daystamp.swift in Sources */,
E458C8042AD11BC3000DCA5C /* SignedRequestManager.swift in Sources */,
E458C8162AD11CA2000DCA5C /* HealthKitError.swift in Sources */,
9B1DCA5B2D10EA76006A64D9 /* ToothbrushingHealthKitMetric.swift in Sources */,
9B1DCA5B2D10EA76006A64D9 /* ToothbrushingDailyMinutesHealthKitMetric.swift in Sources */,
E458C81E2AD11D05000DCA5C /* DateUtils.swift in Sources */,
E4B0A33128C194C900055EA7 /* AddDataIntents.intentdefinition in Sources */,
E458C8132AD11C94000DCA5C /* HealthKitMetric.swift in Sources */,
Expand Down Expand Up @@ -1119,7 +1119,7 @@
E46071012B451FA400305DB4 /* BeeminderModel.xcdatamodeld in Sources */,
E458C80D2AD11C64000DCA5C /* Crypto.swift in Sources */,
E458C8012AD11BB3000DCA5C /* RequestManager.swift in Sources */,
9B7D44662D12C304003B62B1 /* ToothbrushingSessionsHealthKitMetric.swift in Sources */,
9B7D44662D12C304003B62B1 /* ToothbrushingDailySessionsHealthKitMetric.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit 4eea411

Please sign in to comment.