openfoodfacts / openfoodfacts-server

Open Food Facts database, API server and web interface - 🐪🦋 Perl, CSS and JS coders welcome 😊 For helping in Python, see Robotoff or taxonomy-editor
http://openfoodfacts.github.io/openfoodfacts-server/
GNU Affero General Public License v3.0
652 stars 381 forks source link

Make allergens and traces values supplied by producers completely replace existing values #8522

Closed stephanegigandet closed 1 year ago

stephanegigandet commented 1 year ago

The usual behaviour for "tags" fields such as categories, labels, countries, allergens etc. is that values supplied by producers are added to any existing value entered by users (e.g. producers might sent us only the "Organic" label while we may have more precise labels and mentions such as "AB Organic" or "Rich in fiber").

For allergens and traces though, if the producer sends a value, we can assume that the value is complete, and that it can replace entirely any pre-existing value.

We need to do 2 things:

  1. On the pro platform, when importing allergens and traces, if the producers supplies a value (non empty), then we replace existing values.
  2. When exporting data from the pro platform and importing it to the public platform, if there is a non empty value for allergens, we replace existing values.

Related to https://github.com/openfoodfacts/openfoodfacts-server/issues/7850

Part of

MonalikaPatnaik commented 1 year ago

Working on this! Could you pls tell me the relevant code file to make desired changes :')

stephanegigandet commented 1 year ago

Related code: probably in lib/ProductOpener/Import.pm there are test files t/integration/import_csv_file.t

fields that should be protected should be configured in Config_off.pm, at the beginning it will be allergens and traces, but we might add other fields later.