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

Prepared nutrition facts are not displayed #2177

Open
teolemon opened this issue Jan 30, 2019 · 9 comments
Open

Prepared nutrition facts are not displayed #2177

teolemon opened this issue Jan 30, 2019 · 9 comments
Labels
bug Produces incorrect or unexpected result or behaviour. nutrition facts

Comments

@teolemon
Copy link
Member

teolemon commented Jan 30, 2019

image
https://world.openfoodfacts.org/product/3033710065967/nesquik-nestle

image
https://world.openfoodfacts.org/api/v0/product/3033710065967.json

You need to concatenate _prepared to the regular values

Example:
https://world.openfoodfacts.org/product/3036812020704/gratinee-oignons-et-croutons-royco
https://world.openfoodfacts.org/api/v0/product/3036812020704.json

{"salt_prepared_100g":0.850000000000001,"carbohydrates_unit":"","sodium_prepared":0.334645669291339,"fiber_prepared_value":"0.2","nutrition-score-fr":"3","proteins_prepared":0.6,"salt_prepared":0.850000000000001,"energy_prepared_serving":"292","fiber_prepared_serving":0.4,"sugars_prepared_value":"0.6","carbohydrates_prepared":"5","saturated-fat_prepared_value":"0.7","energy_prepared":"146","proteins_unit":"","fat_prepared_value":"1.4","sugars_prepared_100g":0.6,"sodium_prepared_serving":0.669,"nutrition-score-uk":"3","energy_prepared_value":"35","salt_unit":"","sodium_prepared_value":"0.334645669291339","nutrition-score-uk_100g":"3","salt_prepared_value":"0.85","saturated-fat_prepared_100g":0.7,"fat_unit":"","saturated-fat_prepared_serving":1.4,"carbohydrates_prepared_serving":"10","fat_prepared_serving":2.8,"sodium_prepared_100g":0.334645669291339,"proteins_prepared_100g":0.6,"sugars_prepared":0.6,"fat_prepared":1.4,"proteins_prepared_serving":1.2,"fiber_unit":"","salt_prepared_serving":1.7,"fiber_prepared_100g":0.2,"proteins_prepared_value":"0.6","fat_prepared_100g":1.4,"sugars_unit":"","sugars_prepared_serving":1.2,"energy_unit":"kcal","nutrition-score-fr_100g":"3","saturated-fat_prepared":0.7,"carbohydrates_prepared_100g":"5","carbohydrates_prepared_value":"5","saturated-fat_unit":"","energy_prepared_100g":"146","fiber_prepared":0.2}

It should probably be additional columns, but raises UX questions, since it can create up to 2 additional columns

@yasnogor
Copy link

yasnogor commented Feb 7, 2019

I'd like to take this one.

@teolemon
Copy link
Member Author

teolemon commented Feb 7, 2019

You can go ahead 👍

@yasnogor
Copy link

yasnogor commented Feb 7, 2019

Actually, it looks like this is working fine now. Might have been fixed by PR #2027.

@teolemon
Copy link
Member Author

teolemon commented Feb 7, 2019

No, someone added more info.
Try with this one: https://barcode.tec-it.com/en/EAN13?data=7613034178527

@teolemon
Copy link
Member Author

teolemon commented Feb 7, 2019

@yasnogor
Copy link

yasnogor commented Feb 8, 2019

It seems that the response from the server and the attributes that come back differs between these products.

Compare:
Has the data - https://world.openfoodfacts.org/api/v0/product/3033710065967.json
carbohydrates_100g
proteins_100g
Does not have this data - https://world.openfoodfacts.org/api/v0/product/7613034178527.json
However, this server response does contain
proteins_prepared_100g
carbohydrates_prepared_100g

Should the app be looking for these later attributes?

@yasnogor
Copy link

It seems that the app code is looking for carbohydrates_100g and such data to be returned. If I change the attributes to carbohydrates_prepared_100g the data shows up fine in app. Should the app code be modified to look for X_prepared_100g if X_100g is not available in json? I'm not sure if this is an appropriate solution though.

@yasnogor
Copy link

I added some code to check if nutrient X_prepared is available in json when X isn't available. However, I'm not sure if this is an appropriate solution from business logic point of view. Does the server side need to be changed instead to include the missing attributes? I can create a PR if you'd like to take a look.

@teolemon
Copy link
Member Author

Depending on what's available (non prepared, prepared, or both), I guess there might be a dropdown at the top of the table enabling to switch
Or we could have a table that scrolls horizontally.
@yasnogor

yasnogor added a commit to yasnogor/openfoodfacts-androidapp that referenced this issue Feb 18, 2019
@teolemon teolemon added the bug Produces incorrect or unexpected result or behaviour. label Dec 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Produces incorrect or unexpected result or behaviour. nutrition facts
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants