Skip to content

Commit 4eea411

Browse files
committed
clean code
1 parent c8f97d6 commit 4eea411

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

BeeKit/HeathKit/HealthKitConfig.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public enum HealthKitConfig {
5252
QuantityHealthKitMetric(humanText: "Water", databaseString: "water", category: .Nutrition, hkQuantityTypeIdentifier: .dietaryWater),
5353

5454
// Self care
55-
ToothbrushingHealthKitMetric.make(),
56-
ToothbrushingSessionsHealthKitMetric.make(),
55+
ToothbrushingDailyMinutesHealthKitMetric.make(),
56+
ToothbrushingDailySessionsHealthKitMetric.make(),
5757

5858
// Sleep
5959
TimeInBedHealthKitMetric(humanText: "Time in bed", databaseString: "timeInBed", category: .Sleep),

BeeKit/HeathKit/Toothbrushing/ToothbrushingHealthKitMetric.swift renamed to BeeKit/HeathKit/Toothbrushing/ToothbrushingDailyMinutesHealthKitMetric.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import Foundation
22
import HealthKit
33

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

88
private init(humanText: String,
99
databaseString: String,
@@ -18,7 +18,7 @@ class ToothbrushingHealthKitMetric: CategoryHealthKitMetric {
1818
HKUnit.second()
1919
}
2020

21-
static func make() -> ToothbrushingHealthKitMetric {
21+
static func make() -> ToothbrushingDailyMinutesHealthKitMetric {
2222
.init(humanText: "Teethbrushing (in seconds per day)",
2323
databaseString: healthkitMetric,
2424
category: HealthKitCategory.SelfCare)
@@ -29,7 +29,7 @@ class ToothbrushingHealthKitMetric: CategoryHealthKitMetric {
2929
.map {
3030
NewDataPoint(requestid: $0.requestid,
3131
daystamp: $0.daystamp,
32-
value: $0.value,
32+
value: NSNumber(value: $0.value.doubleValue / 60),
3333
comment: "Auto-entered via Apple Health (\(Self.healthkitMetric))")
3434
}
3535
}

BeeKit/HeathKit/Toothbrushing/ToothbrushingSessionsHealthKitMetric.swift renamed to BeeKit/HeathKit/Toothbrushing/ToothbrushingDailySessionsHealthKitMetric.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Foundation
44
import HealthKit
55

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

1010
private init(humanText: String,
@@ -20,7 +20,7 @@ class ToothbrushingSessionsHealthKitMetric: CategoryHealthKitMetric {
2020
.count()
2121
}
2222

23-
static func make() -> ToothbrushingSessionsHealthKitMetric {
23+
static func make() -> ToothbrushingDailySessionsHealthKitMetric {
2424
.init(humanText: "Teethbrushing (in sessions per day)",
2525
databaseString: healthkitMetric,
2626
category: HealthKitCategory.SelfCare)

BeeSwift.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
9B1DCA5B2D10EA76006A64D9 /* ToothbrushingHealthKitMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B1DCA5A2D10EA76006A64D9 /* ToothbrushingHealthKitMetric.swift */; };
11-
9B7D44662D12C304003B62B1 /* ToothbrushingSessionsHealthKitMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B7D44652D12C304003B62B1 /* ToothbrushingSessionsHealthKitMetric.swift */; };
10+
9B1DCA5B2D10EA76006A64D9 /* ToothbrushingDailyMinutesHealthKitMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B1DCA5A2D10EA76006A64D9 /* ToothbrushingDailyMinutesHealthKitMetric.swift */; };
11+
9B7D44662D12C304003B62B1 /* ToothbrushingDailySessionsHealthKitMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B7D44652D12C304003B62B1 /* ToothbrushingDailySessionsHealthKitMetric.swift */; };
1212
9B8CA57D24B120CA009C86C2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9B8CA57C24B120CA009C86C2 /* LaunchScreen.storyboard */; };
1313
A10D4E931B07948500A72D29 /* DatapointsTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10D4E921B07948500A72D29 /* DatapointsTableView.swift */; };
1414
A10DC2DF207BFCBA00FB7B3A /* RemoveHKMetricViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10DC2DE207BFCBA00FB7B3A /* RemoveHKMetricViewController.swift */; };
@@ -219,8 +219,8 @@
219219
/* End PBXCopyFilesBuildPhase section */
220220

221221
/* Begin PBXFileReference section */
222-
9B1DCA5A2D10EA76006A64D9 /* ToothbrushingHealthKitMetric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToothbrushingHealthKitMetric.swift; sourceTree = "<group>"; };
223-
9B7D44652D12C304003B62B1 /* ToothbrushingSessionsHealthKitMetric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToothbrushingSessionsHealthKitMetric.swift; sourceTree = "<group>"; };
222+
9B1DCA5A2D10EA76006A64D9 /* ToothbrushingDailyMinutesHealthKitMetric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToothbrushingDailyMinutesHealthKitMetric.swift; sourceTree = "<group>"; };
223+
9B7D44652D12C304003B62B1 /* ToothbrushingDailySessionsHealthKitMetric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToothbrushingDailySessionsHealthKitMetric.swift; sourceTree = "<group>"; };
224224
9B8CA57C24B120CA009C86C2 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
225225
A10D4E921B07948500A72D29 /* DatapointsTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatapointsTableView.swift; sourceTree = "<group>"; };
226226
A10DC2DE207BFCBA00FB7B3A /* RemoveHKMetricViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoveHKMetricViewController.swift; sourceTree = "<group>"; };
@@ -416,8 +416,8 @@
416416
9B7D44642D12C2F3003B62B1 /* Toothbrushing */ = {
417417
isa = PBXGroup;
418418
children = (
419-
9B7D44652D12C304003B62B1 /* ToothbrushingSessionsHealthKitMetric.swift */,
420-
9B1DCA5A2D10EA76006A64D9 /* ToothbrushingHealthKitMetric.swift */,
419+
9B7D44652D12C304003B62B1 /* ToothbrushingDailySessionsHealthKitMetric.swift */,
420+
9B1DCA5A2D10EA76006A64D9 /* ToothbrushingDailyMinutesHealthKitMetric.swift */,
421421
);
422422
path = Toothbrushing;
423423
sourceTree = "<group>";
@@ -1087,7 +1087,7 @@
10871087
E45470282B60E24500EE648B /* Daystamp.swift in Sources */,
10881088
E458C8042AD11BC3000DCA5C /* SignedRequestManager.swift in Sources */,
10891089
E458C8162AD11CA2000DCA5C /* HealthKitError.swift in Sources */,
1090-
9B1DCA5B2D10EA76006A64D9 /* ToothbrushingHealthKitMetric.swift in Sources */,
1090+
9B1DCA5B2D10EA76006A64D9 /* ToothbrushingDailyMinutesHealthKitMetric.swift in Sources */,
10911091
E458C81E2AD11D05000DCA5C /* DateUtils.swift in Sources */,
10921092
E4B0A33128C194C900055EA7 /* AddDataIntents.intentdefinition in Sources */,
10931093
E458C8132AD11C94000DCA5C /* HealthKitMetric.swift in Sources */,
@@ -1119,7 +1119,7 @@
11191119
E46071012B451FA400305DB4 /* BeeminderModel.xcdatamodeld in Sources */,
11201120
E458C80D2AD11C64000DCA5C /* Crypto.swift in Sources */,
11211121
E458C8012AD11BB3000DCA5C /* RequestManager.swift in Sources */,
1122-
9B7D44662D12C304003B62B1 /* ToothbrushingSessionsHealthKitMetric.swift in Sources */,
1122+
9B7D44662D12C304003B62B1 /* ToothbrushingDailySessionsHealthKitMetric.swift in Sources */,
11231123
);
11241124
runOnlyForDeploymentPostprocessing = 0;
11251125
};

0 commit comments

Comments
 (0)