Skip to content

fix(measurements): preserve supplied derived values on insert - #1593

Closed
aronnoordhoek wants to merge 1 commit into
oliexdev:masterfrom
aronnoordhoek:fix/measurement-bmi-save
Closed

aronnoordhoek wants to merge 1 commit into
oliexdev:masterfrom
aronnoordhoek:fix/measurement-bmi-save

Conversation

@aronnoordhoek

Copy link
Copy Markdown
Contributor

Saving values one at a time can calculate BMI before the scale’s BMI is inserted, creating duplicate rows. Recalculating after import can also overwrite supplied derived values.

Save each new measurement and its supplied values in one transaction, then calculate only missing or invalid derived values. Use the same path for single saves, CSV and ContentProvider imports, keeping the existing recalculation rules for edits. Existing duplicate rows are not migrated.

Found while testing Tanita RD-545 support in #1592.

Validation: 1,083 unit tests pass; debug APK builds; instrumented tests compile; lint reports zero errors.

@oliexdev

Copy link
Copy Markdown
Owner

The duplicate rows are fixed on master in a70e938, though not the way this PR does it. A new
measurement is now inserted together with its values in one transaction, followed by a single
recalculation, and editing no longer adds a second row for a recalculated formula value.

What I didn't take over is keeping supplied derived values. Derived values (BMI, BMR, TDEE, ...)
are now always openScale's own calculation, and the connector drops what a scale reports for them.
Otherwise the same measurement would show a different value after an edit, which is the
inconsistency FILL_MISSING would have introduced. BMR instead got a formula setting like body fat
and water (Mifflin-St Jeor, Katch-McArdle, revised Harris-Benedict). For the Tanita PR this means
the scale's BMI and BMR won't be stored. Closing this one.

@oliexdev oliexdev closed this Nov 14, 2026
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.

2 participants