-
-
Notifications
You must be signed in to change notification settings - Fork 446
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
Comments
I'd like to take this one. |
You can go ahead 👍 |
Actually, it looks like this is working fine now. Might have been fixed by PR #2027. |
No, someone added more info. |
It seems that the response from the server and the attributes that come back differs between these products. Compare: Should the app be looking for these later attributes? |
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. |
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. |
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 |
https://world.openfoodfacts.org/product/3033710065967/nesquik-nestle
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
The text was updated successfully, but these errors were encountered: