Request activity feed in smaller chunks during GC trigger polling
@@ -655,14 +655,19 @@ class GarminConnectService(ServiceBase):
# These seems to fail with a 500 (talkking about a timeout) the first time, so keep trying.
SERVER_ERROR_RETRIES = 10
+ PAGE_SIZE = 100
+ TOTAL_SIZE = 1000
# Then, check for users with new activities
+ watch_activities = []
+ for i in range(1, TOTAL_SIZE, PAGE_SIZE):
for x in range(SERVER_ERROR_RETRIES):
self._rate_limit()
- watch_activities_resp = session.get("https://connect.garmin.com/modern/proxy/activitylist-service/activities/subscriptionFeed?limit=1000")
+ watch_activities_resp = session.get("https://connect.garmin.com/modern/proxy/activitylist-service/activities/subscriptionFeed",
+ params={"limit": PAGE_SIZE, "start": i})
if watch_activities_resp.status_code != 500:
break
try:
- watch_activities = watch_activities_resp.json()
+ watch_activities.append(watch_activities_resp.json())
except ValueError:
raise Exception("Could not parse new activities list: %s %s" % (watch_activities_resp.status_code, watch_activities_resp.text))
