fix(sync): support new Garmin API metric format + backfill script + make targets#203
Merged
Conversation
…ake targets Garmin changed activityDetailMetrics from per-metric-type groups (with sequenceNumber) to positional value arrays per timepoint (with a separate metricDescriptors lookup). Old mapper silently produced 0 records for all activities using the new format. - _build_metric_index_v2: handles new format via metricDescriptors + positional array alignment; old _build_metric_index kept for legacy - map_records: auto-detects format by presence of metricDescriptors key - elevation fallback removed: directGrade is a % slope, not elevation in m - get_activities_without_records: new repo method + abstract base declaration; returns activities with 0 records for targeted backfill - backfill_records.py: one-shot script to fetch GPS/HR detail from Garmin for all historical activities missing records; rate-limited (0.5 s between calls) - Makefile: backfill-records target; fix trigger-sync + db targets (DB_APP_USER was read from wrong env file, now hardcoded to garmin_app like backfill-battery) - Tests: 5 new mapper tests for new API format; 2 repository tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Jun 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
activityDetailMetricschanged from per-metric-type groups (withsequenceNumber) to positional value arrays per timepoint (with a separatemetricDescriptorslookup). The old mapper silently returned 0 records for all activities using the new format.directGradeis a % slope value, not elevation in metres — was silently writing wrong datamake backfill-recordsto retroactively fetch GPS/HR detail for historical activities missing recordsmake trigger-syncandmake dbwere readingDB_APP_USERfrom the wrong env file, causingrole "-d" does not existerrorsChanges
mapper.py_build_metric_index_v2for new format; auto-detects viametricDescriptorskey; removesdirectGradeelevation fallbackrepositories/base.pyget_activities_without_recordsmethodrepositories/timescale.pybackfill_records.pyMakefilebackfill-recordstarget; hardcodegarmin_appintrigger-sync+dbtargetstests/test_mapper.pytests/test_repository.pyget_activities_without_recordsTest plan
cd sync-service && .venv/bin/pytest tests/ -v— all tests passmake trigger-sync— no longer errors withrole "-d" does not existmake backfill-records— fetches records for outdoor activities missing GPS/HR data🤖 Generated with Claude Code