openfoodfacts / openfoodfacts-androidapp

(Legacy) Native version of Open Food Facts on Android - Coders & Decoders welcome 🤳🥫
https://android.openfoodfacts.org
Apache License 2.0
775 stars 447 forks source link

Remove nutrient hardcoding (nutrition table/edit mode) using new API #2357

Open teolemon opened 5 years ago

teolemon commented 5 years ago

The API is now available to use: https://fr.openfoodfacts.org/cgi/nutrients.pl

nutritiontable https://world.openfoodfacts.org/product/1/pot-au-feu-golden-viginia

teolemon commented 5 years ago

Currently the nutrient list is harcoded in https://github.com/openfoodfacts/openfoodfacts-androidapp/blob/46a8fbb136d222729011c198bbeca500f0c37668/app/src/main/java/openfoodfacts/github/scrachx/openfood/models/Nutriments.java#L30

However, we have a Taxonomy of nutrients we can refresh. https://static.openfoodfacts.org/data/taxonomies/nutrients.json

VaiTon commented 5 years ago

Also it doesn't show fields like Polyols

VaiTon commented 5 years ago

Currently the nutrient list is harcoded in

https://github.com/openfoodfacts/openfoodfacts-androidapp/blob/46a8fbb136d222729011c198bbeca500f0c37668/app/src/main/java/openfoodfacts/github/scrachx/openfood/models/Nutriments.java#L30

However, we have a Taxonomy of nutrients we can refresh. https://static.openfoodfacts.org/data/taxonomies/nutrients.json

How could we get relations between them? (I'm thinking of minerals, vitamins, etc...) @teolemon

VaiTon commented 5 years ago

Also, if we create a map at runtime, we should change all occurrences like this

if (Nutriments.ENERGY.equals(nutrientShortName)) 
teolemon commented 4 years ago

The API is now available to use: https://fr.openfoodfacts.org/cgi/nutrients.pl