mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
The per-minute steps, calories and distance records set clientRecordVersion to the metric value itself. Health Connect keeps the record with the highest clientRecordVersion on a clientRecordId collision (newVersion >= existing overwrites), so each minute became pinned to the largest value ever sent for it. When a device delivers activity in two phases and revises a minute's value downward between them, the corrected record carries a lower version and is silently ignored, leaving Health Connect above the device's own total. Stamp clientRecordVersion with the sync run's wall-clock instead, shared by every record in the slice. A later run always outranks the value it previously wrote for a minute, so the freshest re-read wins regardless of whether the value rose or fell. The clientRecordId remains the dedup key and is unchanged.