For some metrics (principally active calories) we notice apple calling
our observer query a very large number of times in short succession. This
results in us doing duplicated work. Avoid this by rate limiting how often
we will do an update. This will not affect manual updates by pressing the
sync button.
Note that we still debounce even if an update fails. This seems more or less
reasonable - if an update fails we have no particular reason to believe a retry
will succeed, and we'll get it on the next update.
Testing:
Ran on device and observed logs showing multiple updates are skipped.
For some metrics (principally active calories) we notice apple calling our observer query a very large number of times in short succession. This results in us doing duplicated work. Avoid this by rate limiting how often we will do an update. This will not affect manual updates by pressing the sync button.
Note that we still debounce even if an update fails. This seems more or less reasonable - if an update fails we have no particular reason to believe a retry will succeed, and we'll get it on the next update.
Testing: Ran on device and observed logs showing multiple updates are skipped.