brandonp2412 / FitBook

Track your calorie intake - Completely offline
MIT License
51 stars 4 forks source link

Fix per gram calculation #6

Closed kirvlasov closed 3 months ago

kirvlasov commented 3 months ago

Reference values are always per 100g, not per 1st serving value.

You can check it yourself, compare the values with what google finds about their nutrition. Screenshot_20240616_001609_Firefox Screenshot_20240616_001420

brandonp2412 commented 3 months ago

This would defeat the purpose of setting the serving size on foods. Please explain the bug this fixes, the steps to re-produce and what you expect to happen.

kirvlasov commented 3 months ago

Whether it defeats or not, the calculation is not correct now. I updated the starter of the conversation with an example.

kirvlasov commented 3 months ago

Sorry, here is the third screenshot to understand the issue Screenshot_20240616_002120 As you see, when we input 100 grams, the data doesn't match the reference values I showed before

brandonp2412 commented 3 months ago

Your above example doesn't look like a bug to me. You set your food to be 61 calories per 244 grams, then you entered 100 grams.

61 / 244 = 0.25 0.25 * 100 = 25

kirvlasov commented 3 months ago

I don't set my food. That's the database that you provide with the App. And this database contains nutrition facts per 100 g, not per first serving size.

kirvlasov commented 3 months ago

So the way you calculate nutrition facts per gram now, it's always returning incorrect values for the whole database except for items where 1st serving size is 100g

brandonp2412 commented 3 months ago

Oh I see what happened now it's because I've conflated these new fields with the old ones

brandonp2412 commented 3 months ago

I need to add a new field for the user specified serving size, and move this MyFoodData field serving weight back below with the other fields, then it defaults to 100 if the user hasn't specified a serving size.

kirvlasov commented 3 months ago

I will be happy with any solution that fixes the App!

brandonp2412 commented 3 months ago

Sadly this will make some peoples entries incorrect if they took a version of the app with this bug and started editing the servingWeight1G field, this will however fix all the built-in foods which there are so many it's worth doing.