Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editing a product with additional nutrients will erroneously change the recorded values of these nutrients on save #4145

Closed
Tracked by #4457
JeanFred opened this issue Aug 8, 2021 · 7 comments · Fixed by #4171
Labels
editing Issues relating to allowing the user to edit products nutrition editing nutrition facts

Comments

@JeanFred
Copy link

JeanFred commented Aug 8, 2021

Describe the bug

When editing a product with additional nutrients recorded (eg Vitamin D), the additional Nutrient values will be changed on save (even when not edited),

To Reproduce
Steps to reproduce the behavior:

  1. Edit a product with at least one additional nutrient
  2. Change something (eg a Label) (but not the nutrient)
  3. Save

Expected behavior
The nutrient value do not get changed.

Actual behaviour
The nutrient value is divided by 1000.

Example
See my edits on the product https://world.openfoodfacts.org/product/4001497280001/ :

Smartphone (please complete the following information):

  • Device: Fairphone 3+
  • Version 3.6.8
@VaiTon
Copy link
Member

VaiTon commented Aug 9, 2021

More info: it happens only when selecting mg or ug

@VaiTon
Copy link
Member

VaiTon commented Aug 9, 2021

immagine
@teolemon @stephanegigandet

I inputed 10 mg and this is the result. Should we take the _value?

@teolemon
Copy link
Member

Is this a sever side or client side issue @VaiTon ?

@stephanegigandet
Copy link

_value and _unit are internal data, they should not be read by the app. Use the _100g field instead. It is always in grams.

@VaiTon
Copy link
Member

VaiTon commented Aug 10, 2021

@stephanegigandet we need to use the _unit to set the unit spinner in the app.

Otherwise what abount taking the value in 100g and then finding the most appropriate unit?
cc @teolemon

@stephanegigandet
Copy link

Otherwise what abount taking the value in 100g and then finding the most appropriate unit?

That's the best thing to do.

@VaiTon VaiTon pinned this issue Aug 13, 2021
@teolemon teolemon added editing Issues relating to allowing the user to edit products nutrition facts labels Aug 21, 2021
VaiTon added a commit that referenced this issue Aug 22, 2021
ref: use extension functions to query db

Closes #4145
VaiTon added a commit that referenced this issue Aug 24, 2021
* fix: refactored measurements inner working
* ref: use extension functions to query db

Closes #4145

Co-authored-by: naivekook <tanakov.dev@gmail.com>
@teolemon
Copy link
Member

Ok, so my edits do not seem taken into account

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editing Issues relating to allowing the user to edit products nutrition editing nutrition facts
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants