Skip to content

Commit 3784a6a

Browse files
committed
1.6.1 preps, returning a collection of HR series
1 parent 0cbdaaa commit 3784a6a

File tree

12 files changed

+120
-113
lines changed

12 files changed

+120
-113
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.6.1] - 15.10.2021.
2+
3+
* return HeartbeatSeries as a collection of samples, each has own collection of measurements
4+
15
## [1.6.0] - 12.10.2021.
26

37
* heartbeatSeriesQuery changed as HeartbeatSeries now is a valid sample with a set of beat by beat measurements

Example/HealthKitReporter.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@
474474
GCC_WARN_UNUSED_FUNCTION = YES;
475475
GCC_WARN_UNUSED_VARIABLE = YES;
476476
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
477-
MARKETING_VERSION = 1.6.0;
477+
MARKETING_VERSION = 1.6.1;
478478
MTL_ENABLE_DEBUG_INFO = YES;
479479
ONLY_ACTIVE_ARCH = YES;
480480
SDKROOT = iphoneos;
@@ -525,7 +525,7 @@
525525
GCC_WARN_UNUSED_FUNCTION = YES;
526526
GCC_WARN_UNUSED_VARIABLE = YES;
527527
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
528-
MARKETING_VERSION = 1.6.0;
528+
MARKETING_VERSION = 1.6.1;
529529
MTL_ENABLE_DEBUG_INFO = NO;
530530
SDKROOT = iphoneos;
531531
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";

Example/HealthKitReporter_Example.entitlements

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@
66
<true/>
77
<key>com.apple.developer.healthkit.access</key>
88
<array/>
9+
<key>com.apple.developer.healthkit.background-delivery</key>
10+
<true/>
911
</dict>
1012
</plist>

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 6 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HealthKitReporter.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'HealthKitReporter'
11-
s.version = '1.6.0'
11+
s.version = '1.6.1'
1212
s.summary = 'HealthKitReporter. A wrapper for HealthKit framework.'
1313
s.swift_versions = '5.3'
1414
s.description = 'Helps to write or read data from Apple Health via HealthKit framework.'

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ pod 'HealthKitReporter'
305305
or
306306

307307
```ruby
308-
pod 'HealthKitReporter', '~> 1.6.0'
308+
pod 'HealthKitReporter', '~> 1.6.1'
309309
```
310310

311311
### Swift Package Manager
@@ -315,7 +315,7 @@ To install it, simply add the following lines to your Package.swift file
315315

316316
```swift
317317
dependencies: [
318-
.package(url: "https://github.com/VictorKachalov/HealthKitReporter.git", from: "1.6.0")
318+
.package(url: "https://github.com/VictorKachalov/HealthKitReporter.git", from: "1.6.1")
319319
]
320320
```
321321

@@ -324,7 +324,7 @@ dependencies: [
324324
Add the line in your cartfile
325325

326326
```ruby
327-
github "VictorKachalov/HealthKitReporter" "1.6.0"
327+
github "VictorKachalov/HealthKitReporter" "1.6.1"
328328
```
329329

330330
## Author

Sources/Decorator/Extensions+HKHeartbeatSeriesSample.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import HealthKit
1010

1111
@available(iOS 13.0, *)
1212
extension HKHeartbeatSeriesSample {
13-
typealias Harmonized = HeartbeatSeriesSample.Harmonized
13+
typealias Harmonized = HeartbeatSeries.Harmonized
1414

15-
func harmonize(series: [HeartbeatSeries]) -> Harmonized {
15+
func harmonize(measurements: [HeartbeatSeries.Measurement]) -> Harmonized {
1616
Harmonized(
1717
count: count,
18-
series: series,
18+
measurements: measurements,
1919
metadata: metadata?.compactMapValues { String(describing: $0) }
2020
)
2121
}

Sources/HealthKitReporter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ public typealias AnchoredResultsHandler = (
8282
) -> Void
8383
/**
8484
- Parameters:
85-
- series: heartbeat serie.
85+
- series: heartbeat series.
8686
- error: error (optional)
8787
*/
8888
@available(iOS 13.0, *)
8989
public typealias HeartbeatSeriesResultsDataHandler = (
90-
_ samples: [HeartbeatSeriesSample],
90+
_ series: [HeartbeatSeries],
9191
_ error: Error?
9292
) -> Void
9393
/**

Sources/Model/Payload/HeartbeatSeries.swift

Lines changed: 76 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,88 @@
22
// HeartbeatSeries.swift
33
// HealthKitReporter
44
//
5-
// Created by Victor on 25.09.20.
5+
// Created by Kachalov, Victor on 12.10.21.
66
//
77

88
import Foundation
9+
import HealthKit
910

10-
public struct HeartbeatSeries: Codable {
11-
public let timeSinceSeriesStart: Double
12-
public let precededByGap: Bool
13-
public let done: Bool
11+
@available(iOS 13.0, *)
12+
public struct HeartbeatSeries: Identifiable, Sample {
13+
public struct Measurement: Codable {
14+
public let timeSinceSeriesStart: Double
15+
public let precededByGap: Bool
16+
public let done: Bool
17+
public init(
18+
timeSinceSeriesStart: Double,
19+
precededByGap: Bool,
20+
done: Bool
21+
) {
22+
self.timeSinceSeriesStart = timeSinceSeriesStart
23+
self.precededByGap = precededByGap
24+
self.done = done
25+
}
26+
}
27+
28+
public struct Harmonized: Codable {
29+
public let count: Int
30+
public let measurements: [Measurement]
31+
public let metadata: [String: String]?
32+
33+
public init(
34+
count: Int,
35+
measurements: [Measurement],
36+
metadata: [String: String]?
37+
) {
38+
self.count = count
39+
self.measurements = measurements
40+
self.metadata = metadata
41+
}
1442

43+
public func copyWith(
44+
count: Int? = nil,
45+
measurements: [Measurement]? = nil,
46+
metadata: [String: String]? = nil
47+
) -> Harmonized {
48+
return Harmonized(
49+
count: count ?? self.count,
50+
measurements: measurements ?? self.measurements,
51+
metadata: metadata ?? self.metadata
52+
)
53+
}
54+
}
55+
56+
public let uuid: String
57+
public let identifier: String
58+
public let startTimestamp: Double
59+
public let endTimestamp: Double
60+
public let device: Device?
61+
public let sourceRevision: SourceRevision
62+
public let harmonized: Harmonized
63+
1564
public init(
16-
timeSinceSeriesStart: Double,
17-
precededByGap: Bool,
18-
done: Bool
65+
identifier: String,
66+
startTimestamp: Double,
67+
endTimestamp: Double,
68+
device: Device?,
69+
sourceRevision: SourceRevision,
70+
harmonized: Harmonized
1971
) {
20-
self.timeSinceSeriesStart = timeSinceSeriesStart
21-
self.precededByGap = precededByGap
22-
self.done = done
72+
self.uuid = UUID().uuidString
73+
self.identifier = identifier
74+
self.startTimestamp = startTimestamp
75+
self.endTimestamp = endTimestamp
76+
self.device = device
77+
self.sourceRevision = sourceRevision
78+
self.harmonized = harmonized
79+
}
80+
init(sample: HKHeartbeatSeriesSample, measurements: [Measurement]) {
81+
self.uuid = sample.uuid.uuidString
82+
self.identifier = sample.sampleType.identifier
83+
self.startTimestamp = sample.startDate.timeIntervalSince1970
84+
self.endTimestamp = sample.endDate.timeIntervalSince1970
85+
self.device = Device(device: sample.device)
86+
self.sourceRevision = SourceRevision(sourceRevision: sample.sourceRevision)
87+
self.harmonized = sample.harmonize(measurements: measurements)
2388
}
2489
}

Sources/Model/Payload/HeartbeatSeriesSample.swift

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)