beeminder / BeeSwift

Official Beeminder for iOS app
Other
29 stars 5 forks source link

Make fewer API calls in response to HealthKit Updates #318

Closed theospears closed 1 year ago

theospears commented 1 year ago

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