Fix Garmin Connect sync to import full history and prevent re-downloads
Activity sync: - First sync (no last_sync_at) now fetches from 2010-01-01 instead of -30 days, importing the full account history rather than only the last month - Pre-download dedup: check existing activities by start_time before downloading; stamps garmin_activity_id on the match so subsequent syncs take the fast path - process_activity_file stamps garmin_activity_id on duplicate detection for the same reason (covers activities imported via bulk export) - 0.5 s sleep between downloads to avoid Garmin API rate limiting Wellness sync: - First sync now covers last 90 days instead of 7 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -93,6 +93,11 @@ def process_activity_file(self, file_path: str, user_id: int, source_type: str,
|
||||
).scalar_one_or_none()
|
||||
|
||||
if existing:
|
||||
# Stamp garmin_activity_id if this came from a Garmin Connect sync
|
||||
# so future syncs skip the fast-path dedup and don't re-download.
|
||||
if garmin_activity_id and not existing.garmin_activity_id:
|
||||
existing.garmin_activity_id = garmin_activity_id
|
||||
db.commit()
|
||||
return {"activity_id": existing.id, "status": "duplicate"}
|
||||
|
||||
# Get user max HR for zone calculation
|
||||
|
||||
Reference in New Issue
Block a user