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
GNU Affero General Public License v3.0
633 stars 371 forks source link

Show the Nutri-Score provided by producers when it is available #8549

Open stephanegigandet opened 1 year ago

stephanegigandet commented 1 year ago

Some producers send us data for their products including the Nutri-Score grade (and sometimes the underlying Nutri-Score score as well), in particular through GS1.

Currently we do not display this score, but instead display the score that we compute from nutrition facts.

The issue is that sometimes we have a wrong computed Nutri-Score, for a variety of reasons:

It is now very rare that producers send a wrong Nutri-Score, so we would like to display the producer supplied Nutri-Score in the product attributes and knowledge panels that we show on the website and in the app. In the details, it would still be possibly to mention the source (producer or computed) and highlight any discrepancy that might exist (just as we have warnings to explain the fruits/vegetables are estimated, or the fibers unknown).

This will also motivate more producers to send us data directly, including Nutri-Score data.

CharlesNepote commented 1 year ago

It's not easy to comment, as it's hard to understand the underlying rules and see all the implications.

I think we should firstly build a schema with all the different cases. I have started this one but I have missed some cases and some actions (eg. what is exported in the CSV file?). It can be a base to talk. @stephanegigandet don't hesitate to copy/paste the code or modify my comment. (You can modify the schema with https://mermaid.live .)

flowchart TD
    A[NS from producer \n NSFP] -->|sent thru pro platform| B[nutriscore_grade_from_producer field]
    I[NS computed by OFF \n NSC] --> J[nutriscore_grade field]
    G[NS label from producer or user \n NSL] --> H[label field]
    P[NS detected by Robotoff \n -- from last picture? \n NSR]
    O[NS displayed on last version of the product, \n perhaps seen by the user]
    K[NS displayed on our last product's photo \n NSPF] --> C
    B --> C{analyze}
    H --> C
    J --> C
    C -->|NSFP <> NSC \n and NSFP is newer than NSC| D[nutriscore_grade_from_producer is diplayed with a warning:\nNS from producer is different from the one we compute due to lack of data from the producer]
    C -->|NSFP <> NSC and NSFP > 1 year \n and NSC is newer than NSFP| E[display NSC]
    C -->|NSL <> NSFP| F[trigger data-quality-error to let \n data quality team override producer's data]
    C -->|NSPF is at least one year older than NSFP| M[trigger data-quality-warning for the producer \n and for the users]
    M --> N[Ask mobile user to take another photo]
github-actions[bot] commented 10 months ago

This issue has been open 90 days with no activity. Can you give it a little love by linking it to a parent issue, adding relevant labels and projets, creating a mockup if applicable, adding code pointers from https://github.com/openfoodfacts/openfoodfacts-server/blob/main/.github/labeler.yml, giving it a priority, editing the original issue to have a more comprehensive description… Thank you very much for your contribution to 🍊 Open Food Facts