Previously each time we processed new HealthKit data we would fetch recent datapoints once per day, rather than fetching them all together. This was exacerbated by often receiving multiple callbacks for each metric from Apple. The combined impact placed notable load on the Beeminder API servers.
Here we mitigate this by fetching datapoints for each goal once per apple update, rather than once per apple update per day of data. We still end up making more requests than needed, but should be a substantial decrease in server load.
Test Plan:
Observed that metrics still updated in the background
Added logging, and observed number of requests has reduced
Previously each time we processed new HealthKit data we would fetch recent datapoints once per day, rather than fetching them all together. This was exacerbated by often receiving multiple callbacks for each metric from Apple. The combined impact placed notable load on the Beeminder API servers.
Here we mitigate this by fetching datapoints for each goal once per apple update, rather than once per apple update per day of data. We still end up making more requests than needed, but should be a substantial decrease in server load.
Test Plan: Observed that metrics still updated in the background Added logging, and observed number of requests has reduced