This is close to a rewrite of the healthkit implementation, although done through a large number of incremental changes. This is a mix of code structure changes and behavior changes.
Code structure and infrastructure changes:
HealthKit related code is split into a number of classes. Metrics are responsible for fetching this data, and there is a Connection object responsible for tracking the connection between a metric and a goal.
Metrics which have different behavior are handled through subclassing.
HealthKit related code is rewritten to use swift async contructs rather than callbacks. This makes it easier to ensure callbacks are only triggered once when complete.
We now always only update a given goal once per data change trigger, and only fetch datapoints once no matter how many days are updated
Adds some high level logging to track healthkit metric updates
User visible changes:
We correctly update sleep related metrics when updating only a single day
Observer queries are now used for all metrics (not just category metrics) so we more reliably trigger updates in response to metric changes
Test Plan:
Manually synced 1/7 days for various metrics and observe the values sync, and have the same values as before
Ran with this build on my phone for a few days without launching and observed metrics updated in the background
Ran some intermediate builds with a significant amount of logging and checked the logs
This is close to a rewrite of the healthkit implementation, although done through a large number of incremental changes. This is a mix of code structure changes and behavior changes.
Code structure and infrastructure changes:
User visible changes:
Test Plan: