Skip to content

Upgrade weight-only raw Wi-Fi syncs when the full body-comp record arrives#49

Merged
sturimcode merged 1 commit into
mainfrom
fix-raw-record-upgrade
Jul 10, 2026
Merged

Upgrade weight-only raw Wi-Fi syncs when the full body-comp record arrives#49
sturimcode merged 1 commit into
mainfrom
fix-raw-record-upgrade

Conversation

@sturimcode

Copy link
Copy Markdown
Owner

Fixes #48.

The problem

The raw Wi-Fi fallback (#46) syncs a weight-only measurement when the phone app hasn't processed a weigh-in yet. If the user later opens the app, the same weigh-in comes back as a processed record with full body composition, and one of two bad things happened:

  • Different measurement ids (raw timestamp vs processed update_time): both records synced and Garmin got a same-day duplicate.
  • Same ids: the processed record was skipped as already synced, so the user kept weight-only and never got body fat, muscle mass, etc.

The fix

One mechanism covers both cases:

  • Raw measurements carry a weight_only flag, stored in the sync database (with a migration for existing databases; old rows all predate the raw fallback, so they are correctly treated as full records).
  • When a full record arrives for a local date that has a pending weight-only sync, the weight-only entry is deleted from Garmin first (matched by weight within 0.1 kg, fail-open) and the full record uploads in its place. State marks the old row upgraded so it never matches again.
  • A raw record that was skipped (another source already had the date in Garmin) is never marked upgradable, so we can't delete an entry that isn't ours.
  • Strava is untouched: it only holds a single current weight, so both failure modes were harmless there.

If the delete fails, the upload proceeds anyway. Worst case is the duplicate we already had, and the body comp still lands.

Tests

13 new tests across all four layers (parser flag, state tracking and migration, Garmin delete, and full sync flows for both failure modes plus regression guards for the corrected re-weigh and other-source cases). 277 pass.

🤖 Generated with Claude Code

…rives; 1.7.20

The raw Wi-Fi fallback syncs a weight-only measurement when the phone
app hasn't processed a weigh-in yet. When the app later processes the
same weigh-in, the processed record either duplicated the day in Garmin
(ids differ) or was skipped as already synced, stranding the user on
weight-only (ids match).

Raw measurements are now flagged weight_only in the sync database. When
a full record arrives for a local date with a pending weight-only sync,
the weight-only Garmin entry is deleted (matched by weight, fail-open)
and the full record uploads in its place.

Fixes #48

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sturimcode sturimcode merged commit 530e096 into main Jul 10, 2026
4 checks passed
@sturimcode sturimcode deleted the fix-raw-record-upgrade branch July 10, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raw Wi-Fi weight-only record can duplicate or block the later full body-comp record

1 participant