Skip to content

Conversation

@Gtt1229
Copy link
Contributor

@Gtt1229 Gtt1229 commented Jan 9, 2026

This is my take on my feature request:

#468

Creates an option (disabled by default) that can be toggled that will enable scaling of serving size automatically form OpenFoodFacts

I am not too confident in my implementation for best practices of this project as a whole, so please forgive me.

@CodeWithCJ
Copy link
Owner

Could you attach screenshots to understand better on this.

@Gtt1229
Copy link
Contributor Author

Gtt1229 commented Jan 9, 2026

  • Adds the following setting:
image

Example food stats:

Nutrition facts As soldfor 100 g / 100 ml As soldper serving (1 patty (64 g))
Energy 784 kj(188 kcal) 502 kj(120 kcal)
  • THIS IS UNCHANGED! During Import (Normal display of Search and Add Food remains):
image
  • After clicking "Edit and Add" the scaling of 1 serving is applied during import, rather than having to scale, then adjust:
image

It utilizes the serving size to perform a scaling factor to apply to the nutriments. If it is disabled or the serving size is already 100g, the import is unaffected/not-scaled.

@CodeWithCJ CodeWithCJ marked this pull request as ready for review January 9, 2026 02:19
@CodeWithCJ
Copy link
Owner

CodeWithCJ commented Jan 9, 2026

is anything pending or shall i go ahead & merge it? where you able to test that it doesn't affect other food providers?

@Gtt1229
Copy link
Contributor Author

Gtt1229 commented Jan 9, 2026

I unfortunately don't have any other providers to test at the moment. I can set one up some time today; with that, the scaling takes place in the convertOpenFoodFactsToFood constant, so I don't foresee it affecting other imports.

@CodeWithCJ
Copy link
Owner

Hi @Gtt1229 there was a big change from another PR. So I had to hold this one as the other one involved changing lot of pages. Now your PR has some conflict. could you re-submit again. sorry for the inconvenience. Thanks for your help..

@Gtt1229
Copy link
Contributor Author

Gtt1229 commented Jan 11, 2026

Hi @Gtt1229 there was a big change from another PR. So I had to hold this one as the other one involved changing lot of pages. Now your PR has some conflict. could you re-submit again. sorry for the inconvenience. Thanks for your help..

I made the changes, just looks like the lists were cleaned up. I will test my instance later today, please hold on merge.

@Gtt1229
Copy link
Contributor Author

Gtt1229 commented Jan 11, 2026

I added identical logic to the search results for OpenFoodFacts as well for alignment:

image

Tested and ready to go.

@CodeWithCJ CodeWithCJ merged commit 493339e into CodeWithCJ:main Jan 11, 2026
1 check passed
@frozendevl
Copy link

frozendevl commented Jan 16, 2026

@Gtt1229 @CodeWithCJ Just wanted to say THANK YOU for adding auto scaling, incredibly useful and solves one of my biggest gripes with adding new food. Do I need to check "auto-scale" on the Add Custom Food screen? I've been clicking it because it seems to not work otherwise, but wanted to see if it's user error somewhere. Also, is it possible to do the same for "FatSecret" provider? I've had better luck using them (larger database and faster results).

@Gtt1229
Copy link
Contributor Author

Gtt1229 commented Jan 16, 2026

@Gtt1229 Just wanted to say THANK YOU for adding auto scaling, incredibly useful and solves one of my biggest gripes with adding new food. Do I need to check "auto-scale" on the Add Custom Food screen? I've been clicking it because it seems to not work otherwise, but wanted to see if it's user error somewhere. Also, is it possible to do the same for "FatSecret" provider? I've had better luck using them (larger database and faster results).

Of course!

And its 2 different things. Under Settings -> Preferences -> You have to enable and save: Auto-scale OpenFoodFacts Imports.

The treatment following is the results from OoenFoodFacts will be scaled to the serving size during import.

Auto scale can be used in the event you need to change during import (or edits in general).

Basically, I generally do 2 entries for my imports. 1 entry for the grams, and then another duplicate entry as the default for "prices/bar/serving/etc". If you don't do the grams, you can't reliably do measurement if you need it. I'll upload some images of the whole process later today to better specify.

@CodeWithCJ
Copy link
Owner

I'll upload some images of the whole process later today to better specify.

If possible, submit as PR to improve the doc on this part..

@Gtt1229
Copy link
Contributor Author

Gtt1229 commented Jan 17, 2026

@frozendevl

Here is the documentation breaking it all down: https://codewithcj.github.io/SparkyFitness/features/settings/preferences

I'll take a look at FatSecret. Never used it.

@Gtt1229
Copy link
Contributor Author

Gtt1229 commented Jan 17, 2026

@frozendevl Based in their API docs, it looks to me like FatSecret should already return results based on their servings sizes.

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.

3 participants