Skip to content

fix(import): Lose It amounts are portions, not servings - #334

Open
jayhemnani9910 wants to merge 1 commit into
TraceApps:devfrom
jayhemnani9910:fix/loseit-quantity-total
Open

jayhemnani9910 wants to merge 1 commit into
TraceApps:devfrom
jayhemnani9910:fix/loseit-quantity-total

Conversation

@jayhemnani9910

Copy link
Copy Markdown

The Lose It! import multiplies each entry's calories by its logged amount. With rows from a real Lose It food-log export:

Date,Name,Icon,Type,Quantity,Units,Calories,...
08/27/2025,Porridge Oats,Cereal,Breakfast,50.0,Grams,185,...
08/27/2025,Kefir,MilkShake,Breakfast,250.0,Milliliters,116,...

the oats are stored as quantity 50 with 185 kcal per serving, so the diary counts 9,250 kcal. The day comes to 38,355 kcal instead of 406.

Lose It's Calories and nutrient columns are already the totals for the logged amount. parseLoseit put that amount into quantity, which Nutrition.calculate multiplies by. It now emits quantity: 1 with the amount as portion and the unit as unit, the shape the Cronometer and spreadsheet importers already use for the same reason.

Added scripts/nutrition-import-loseit.test.js with the oats row; it fails without the change. node --test scripts/*.test.js shows the same 18 failures with and without the change.

Lose It's Calories and nutrient columns are the totals for the logged amount,
but the importer stored that amount (50 grams) as the serving count, which the
diary multiplies by: 50 g of oats came in as 9,250 kcal. Store one serving with
the amount and unit as the portion, like the Cronometer and spreadsheet
importers.
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.

1 participant