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

fix: indicate some attributes have only mandatory / not_important options #10846

Merged
merged 2 commits into from
Oct 2, 2024

Conversation

stephanegigandet
Copy link
Contributor

@stephanegigandet stephanegigandet commented Sep 30, 2024

This changes the result of http://wold.openfoodfacts.org/api/v2/attribute_groups to add a "values" array to list the possible values for each attribute.

Fixes #9370

Most attributes have 4:

values: [
"not_important",
"important",
"very_important",
"mandatory"
]

Allergens + vegan and vegetarian have 2:

values: [
"not_important",
"mandatory"
]

Full file:

[
{
attributes: [
{
default: "very_important",
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/nutriscore-a.svg",
id: "nutriscore",
name: "Nutri-Score",
panel_id: "nutriscore",
setting_name: "Good nutritional quality (Nutri-Score)",
setting_note: "The Nutri-Score is computed and can be taken into account for all products, even if is not displayed on the packaging.",
values: [
"not_important",
"important",
"very_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/nutrient-level-salt-low.svg",
id: "low_salt",
name: "Salt",
setting_name: "Salt in low quantity",
setting_note: "The salt level is taken into account by the Nutri-Score. Use this setting only if you are specifically on a low salt diet.",
values: [
"not_important",
"important",
"very_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/nutrient-level-sugars-low.svg",
id: "low_sugars",
name: "Sugars",
setting_name: "Sugars in low quantity",
setting_note: "The sugars level is taken into account by the Nutri-Score. Use this setting only if you are specifically on a low sugars diet.",
values: [
"not_important",
"important",
"very_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/nutrient-level-fat-low.svg",
id: "low_fat",
name: "Fat",
setting_name: "Fat in low quantity",
setting_note: "The fat level is taken into account by the Nutri-Score. Use this setting only if you are specifically on a low fat diet.",
values: [
"not_important",
"important",
"very_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/nutrient-level-saturated-fat-low.svg",
id: "low_saturated_fat",
name: "Saturated fat",
setting_name: "Saturated fat in low quantity",
setting_note: "The saturated fat level is taken into account by the Nutri-Score. Use this setting only if you are specifically on a low saturated fat diet.",
values: [
"not_important",
"important",
"very_important",
"mandatory"
]
}
],
id: "nutritional_quality",
name: "Nutritional quality"
},
{
attributes: [
{
default: "important",
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/nova-group-1.svg",
id: "nova",
name: "NOVA group",
panel_id: "nova",
setting_name: "No or little food processing (NOVA group)",
values: [
"not_important",
"important",
"very_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/0-additives.svg",
id: "additives",
name: "Additives",
panel_id: "additives",
setting_name: "No or few additives",
setting_note: "Additives are markers of food processing, and excess consumption of some of them have undesirable health impacts.",
values: [
"not_important",
"important",
"very_important",
"mandatory"
]
}
],
id: "processing",
name: "Food processing"
},
{
attributes: [
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-gluten.svg",
id: "allergens_no_gluten",
name: "Gluten",
setting_name: "Without Gluten",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-milk.svg",
id: "allergens_no_milk",
name: "Milk",
setting_name: "Without Milk",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-eggs.svg",
id: "allergens_no_eggs",
name: "Eggs",
setting_name: "Without Eggs",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-nuts.svg",
id: "allergens_no_nuts",
name: "Nuts",
setting_name: "Without Nuts",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-peanuts.svg",
id: "allergens_no_peanuts",
name: "Peanuts",
setting_name: "Without Peanuts",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-sesame-seeds.svg",
id: "allergens_no_sesame_seeds",
name: "Sesame seeds",
setting_name: "Without Sesame seeds",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-soybeans.svg",
id: "allergens_no_soybeans",
name: "Soybeans",
setting_name: "Without Soybeans",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-celery.svg",
id: "allergens_no_celery",
name: "Celery",
setting_name: "Without Celery",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-mustard.svg",
id: "allergens_no_mustard",
name: "Mustard",
setting_name: "Without Mustard",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-lupin.svg",
id: "allergens_no_lupin",
name: "Lupin",
setting_name: "Without Lupin",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-fish.svg",
id: "allergens_no_fish",
name: "Fish",
setting_name: "Without Fish",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-crustaceans.svg",
id: "allergens_no_crustaceans",
name: "Crustaceans",
setting_name: "Without Crustaceans",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-molluscs.svg",
id: "allergens_no_molluscs",
name: "Molluscs",
setting_name: "Without Molluscs",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/no-sulphur-dioxide-and-sulphites.svg",
id: "allergens_no_sulphur_dioxide_and_sulphites",
name: "Sulphur dioxide and sulphites",
setting_name: "Without Sulphur dioxide and sulphites",
values: [
"not_important",
"mandatory"
]
}
],
id: "allergens",
name: "Allergens",
warning: "There is always a possibility that data about allergens may be missing, incomplete, incorrect or that the product's composition has changed. If you are allergic, always check the information on the actual product packaging."
},
{
attributes: [
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/vegan.svg",
id: "vegan",
name: "Vegan",
setting_name: "Vegan",
setting_note: "To determine whether a product is vegan, we only rely on the list of ingredients.",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/vegetarian.svg",
id: "vegetarian",
name: "Vegetarian",
setting_name: "Vegetarian",
setting_note: "To determine whether a product is vegetarian, we only rely on the list of ingredients.",
values: [
"not_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/palm-oil-free.svg",
id: "palm_oil_free",
name: "Palm oil free",
setting_name: "Palm oil free",
values: [
"not_important",
"important",
"very_important",
"mandatory"
]
}
],
id: "ingredients_analysis",
name: "Ingredients"
},
{
attributes: [
{
description: "Organic farming aims to protect the environment and to conserve biodiversity by prohibiting or limiting the use of synthetic fertilizers, pesticides and food additives.",
description_short: "Organic products promote ecological sustainability and biodiversity.",
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/organic.svg",
id: "labels_organic",
name: "Organic farming",
setting_name: "Organic farming",
values: [
"not_important",
"important",
"very_important",
"mandatory"
]
},
{
description: "When you buy fair trade products, producers in developing countries are paid an higher and fairer price, which helps them improve and sustain higher social and often environmental standards.",
description_short: "Fair trade products help producers in developing countries.",
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/fair-trade.svg",
id: "labels_fair_trade",
name: "Fair trade",
setting_name: "Fair trade",
values: [
"not_important",
"important",
"very_important",
"mandatory"
]
}
],
id: "labels",
name: "Labels"
},
{
attributes: [
{
default: "important",
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/ecoscore-a.svg",
id: "ecoscore",
name: "Eco-Score",
panel_id: "ecoscore",
setting_name: "Low environmental impact (Eco-Score)",
setting_note: "The Eco-Score is an environmental score (ecoscore) from A to E which makes it easy to compare the impact of food products on the environment.",
values: [
"not_important",
"important",
"very_important",
"mandatory"
]
},
{
icon_url: "http://static.openfoodfacts.localhost/images/attributes/dist/forest-footprint-a.svg",
id: "forest_footprint",
name: "Forest footprint",
setting_name: "Low risk of deforestation (Forest footprint)",
setting_note: "The forest footprint corresponds to the risk of deforestation associated with its ingredients.",
values: [
"not_important",
"important",
"very_important",
"mandatory"
]
}
],
id: "environment",
name: "Environment"
}
]

@stephanegigandet stephanegigandet requested a review from a team as a code owner September 30, 2024 14:07
@github-actions github-actions bot added Attributes https://wiki.openfoodfacts.org/Product_Attributes config labels Sep 30, 2024
Copy link

sonarcloud bot commented Sep 30, 2024

@teolemon teolemon requested a review from g123k September 30, 2024 14:18
@teolemon
Copy link
Member

teolemon commented Oct 1, 2024

@g123k is it how you want it to be ?

@g123k
Copy link
Collaborator

g123k commented Oct 1, 2024

@g123k is it how you want it to be ?

Generally speaking, it's OK for me.
My only concern is when we have an entry in several "categories": shouldn't we change the name? And if that's the case, who provides alt labels? (the client? or maybe the server?)

Copy link
Collaborator

@g123k g123k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👌!
Thank you Stephane!

@teolemon
Copy link
Member

teolemon commented Oct 1, 2024

@stephanegigandet @alexgarel some feedback from @g123k

@stephanegigandet
Copy link
Contributor Author

I talked to @g123k on Slack to clarify:

  • at first all allergens will be either not_important or mandatory. We may later add a "Avoid gluten" for people who are gluten intolerant attribute (in addition to the "No gluten" for allergic people), and that one would be not_important, very_important.
  • the names of the attributes come from the server

@stephanegigandet stephanegigandet merged commit 258dc8f into main Oct 2, 2024
13 checks passed
@stephanegigandet stephanegigandet deleted the binary-attributes branch October 2, 2024 07:51
stephanegigandet pushed a commit that referenced this pull request Oct 2, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.45.0](v2.44.0...v2.45.0)
(2024-10-02)


### Features

* Add short name, value and evaluation to knowledge panels
([#9683](#9683))
([bb5c3e2](bb5c3e2))
* enable attributes / personal search on OBF, OPF, OPFF, new config +
logos for OPF & OPFF
([#10757](#10757))
([7e25d9a](7e25d9a))
* make improvements to org table
([#10679](#10679))
([b0cfea1](b0cfea1))
* Small fixes + improvements
([#10818](#10818))
([bd91419](bd91419))


### Bug Fixes

* add Moji server IP to rate-limit allow-list
([#10785](#10785))
([065e0ab](065e0ab))
* add more nutrients to test, to test more things
([#10834](#10834))
([42b341d](42b341d))
* also check .pot GetText files in addition to .po files
([#10827](#10827))
([bb87197](bb87197))
* Determine obsolete and deleted from the product revision
([#10791](#10791))
([508d767](508d767))
* do not localize ecoscore on obf,opf,opff
([#10837](#10837))
([2f93877](2f93877))
* docs Adding closing ) to generate proper internal link
([#10850](#10850))
([492d6d9](492d6d9))
* docs Fixed proper denomination of product in query
([#10853](#10853))
([428dbb3](428dbb3))
* improve OCR JSON generation script
([#10802](#10802))
([3e8fee7](3e8fee7))
* incorrect self-reference in ingredient.yaml
([#10786](#10786))
([2757699](2757699))
* indicate some attributes have only mandatory / not_important options
([#10846](#10846))
([258dc8f](258dc8f))
* invalid type in product_misc.yaml
([#10787](#10787))
([21920a1](21920a1))
* new mongodb exports for obsolete products collection
([#10794](#10794))
([c22fc42](c22fc42))
* permissions for check-translations.sh
([#10838](#10838))
([62e12d6](62e12d6))
* YAML syntax in schema files.
([#10783](#10783))
([959c74c](959c74c))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Attributes https://wiki.openfoodfacts.org/Product_Attributes config
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a new binary property to some preferences, like allergens
3 participants