diff --git a/docs/api/ref/schemas/knowledge_panels/elements/title_element.yaml b/docs/api/ref/schemas/knowledge_panels/elements/title_element.yaml index 03972e2d67ca0..86f4fa1a40bf0 100644 --- a/docs/api/ref/schemas/knowledge_panels/elements/title_element.yaml +++ b/docs/api/ref/schemas/knowledge_panels/elements/title_element.yaml @@ -4,11 +4,20 @@ x-stoplight: type: object description: The title of a panel. properties: + name: + type: string + description: A short name of this panel, not including any actual values title: type: string + type: + type: string + enum: + - grade + - percentage + description: 'Used to indicate how the value of this item is measured, such as "grade" for Nutri-Score and Eco-Score or "percentage" for Salt' grade: type: string - description: Indicates that the panel corresponds to a A to E grade such as the Nutri-Score of the Eco-Score. + description: The value for this panel where it corresponds to a A to E grade such as the Nutri-Score of the Eco-Score. enum: - a - b @@ -16,6 +25,9 @@ properties: - d - e - unknown + value: + type: number + description: 'The numeric value of the panel, where the type is "percentage"' icon_url: type: string icon_color_from_evaluation: @@ -24,7 +36,3 @@ properties: type: string description: | If set to "small", the icon should be displayed at a small size. - type: - type: string - example: grade - description: 'Used to indicate a special type for the title, such as "grade" for Nutri-Score and Eco-Score.' diff --git a/docs/api/ref/schemas/knowledge_panels/panel.yaml b/docs/api/ref/schemas/knowledge_panels/panel.yaml index 8af6380cc86fe..5c3e47082e019 100644 --- a/docs/api/ref/schemas/knowledge_panels/panel.yaml +++ b/docs/api/ref/schemas/knowledge_panels/panel.yaml @@ -13,6 +13,15 @@ properties: expand_for: type: string description: 'If set to "large", the content of the panel should be expanded on large screens, but it should still be possible to unexpand it.' + evaluation: + type: string + description: A simple assessment of the panel value, typically used to format fonts, et.c e.g. bad = red + enum: + - good + - average + - neutral + - bad + - unknown title_element: $ref: ./elements/title_element.yaml elements: diff --git a/lib/ProductOpener/Display.pm b/lib/ProductOpener/Display.pm index 5c728c65c9dba..735b7727f01ed 100644 --- a/lib/ProductOpener/Display.pm +++ b/lib/ProductOpener/Display.pm @@ -9223,6 +9223,8 @@ sub data_to_display_nutrient_levels ($product_ref) { push @{$result_data_ref->{nutrient_levels}}, { nid => $nid, nutrient_level => $product_ref->{nutrient_levels}{$nid}, + evaluation => evaluate_nutrient_level($nid, $product_ref->{nutrient_levels}{$nid}), + nutrient_name => display_taxonomy_tag($lc, "nutrients", "zz:$nid"), nutrient_quantity_in_grams => sprintf("%.2e", $product_ref->{nutriments}{$nid . $prepared . "_100g"}) + 0.0, nutrient_in_quantity => sprintf( diff --git a/lib/ProductOpener/Food.pm b/lib/ProductOpener/Food.pm index 2c35c67154910..56c2735967f16 100644 --- a/lib/ProductOpener/Food.pm +++ b/lib/ProductOpener/Food.pm @@ -73,6 +73,8 @@ BEGIN { &compute_nutrition_data_per_100g_and_per_serving &compute_unknown_nutrients &compute_nutrient_levels + &evaluate_nutrient_level + &compute_units_of_alcohol &compute_estimated_nutrients &compare_nutriments @@ -2490,6 +2492,17 @@ sub compute_nutrient_levels ($product_ref) { return; } +my %nutrient_level_evaluation_table = ( + low => "good", + moderate => "average", + high => "bad", +); + +sub evaluate_nutrient_level ($nid, $nutrient_level) { + # Will need different tables if we add nutrients that are good for you + return $nutrient_level_evaluation_table{$nutrient_level} // 'unknown'; +} + =head2 create_nutrients_level_taxonomy () C creates the source file for the nutrients level diff --git a/lib/ProductOpener/KnowledgePanels.pm b/lib/ProductOpener/KnowledgePanels.pm index 5245cbbef3b9b..2febf7f26cbdf 100644 --- a/lib/ProductOpener/KnowledgePanels.pm +++ b/lib/ProductOpener/KnowledgePanels.pm @@ -607,6 +607,7 @@ sub create_ecoscore_panel ($product_ref, $target_lc, $target_cc, $options_ref, $ "agribalyse_category_name" => $agribalyse_category_name, "agribalyse_score" => $agribalyse_score, "agribalyse_grade" => $agribalyse_grade, + "name" => lang_in_other_lc($target_lc, "attribute_ecoscore_name"), "score" => $score, "grade" => $grade, "title" => $title, @@ -1072,6 +1073,7 @@ sub create_nutriscore_panel ($product_ref, $target_lc, $target_cc, $options_ref) $panel_data_ref->{title} = lang_in_other_lc($target_lc, "attribute_nutriscore_" . $panel_data_ref->{nutriscore_grade} . "_description_short"); } + $panel_data_ref->{name} = lang_in_other_lc($target_lc, "attribute_nutriscore_name"); # Nutri-Score panel: score + details create_panel_from_json_template("nutriscore", "api/knowledge-panels/health/nutriscore/nutriscore.tt.json", diff --git a/templates/api/knowledge-panels/environment/ecoscore/ecoscore.tt.json b/templates/api/knowledge-panels/environment/ecoscore/ecoscore.tt.json index d367523697e86..8d63ba00a9641 100644 --- a/templates/api/knowledge-panels/environment/ecoscore/ecoscore.tt.json +++ b/templates/api/knowledge-panels/environment/ecoscore/ecoscore.tt.json @@ -4,10 +4,11 @@ "environment" ], "title_element": { + "name": "[% panel.name %]", "icon_url": "[% static_subdomain %]/images/attributes/dist/ecoscore-[% panel.grade %].svg", "title": "[% panel.title %]", "type": "grade", - "grade": "[% panel.grade %]", + "grade": "[% panel.grade %]" }, "elements": [ [% IF panel.transportation_warning.defined %] diff --git a/templates/api/knowledge-panels/health/nutriscore/nutriscore.tt.json b/templates/api/knowledge-panels/health/nutriscore/nutriscore.tt.json index 054d0e0564e73..d648cdfa7f1af 100644 --- a/templates/api/knowledge-panels/health/nutriscore/nutriscore.tt.json +++ b/templates/api/knowledge-panels/health/nutriscore/nutriscore.tt.json @@ -8,6 +8,7 @@ [% IF panel.nutriscore_unknown_reason_short %] "subtitle": "[% panel.nutriscore_unknown_reason_short %]", [% END %] + "name": "[% panel.name %]", "title": "[% panel.title %]", "type": "grade", "grade": "[% panel.nutriscore_grade %]", diff --git a/templates/api/knowledge-panels/health/nutrition/nutrient_level.tt.json b/templates/api/knowledge-panels/health/nutrition/nutrient_level.tt.json index 9d5407e556e94..c81f3ea356abf 100644 --- a/templates/api/knowledge-panels/health/nutrition/nutrient_level.tt.json +++ b/templates/api/knowledge-panels/health/nutrition/nutrient_level.tt.json @@ -4,8 +4,12 @@ "health" ], "size": "small", + "half_width_on_mobile": true, "evaluation": "[% panel.evaluation %]", "title_element": { + "name": "[% panel.nutrient_name %]", + "type": "percentage", + "value": [% panel.nutrient_quantity_in_grams %], "title": "[% panel.nutrient_in_quantity %] ([% panel.nutrient_quantity_in_grams %]%)", "icon_url": "[% static_subdomain %]/images/misc/[% panel.nutrient_level %].svg", "icon_size": "small", diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-fields-all-knowledge-panels.json b/tests/integration/expected_test_results/api_v2_product_read/get-fields-all-knowledge-panels.json index 3e796956a76dd..e6cbf11c6d423 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-fields-all-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-fields-all-knowledge-panels.json @@ -884,6 +884,7 @@ "title_element" : { "grade" : "c", "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/dist/ecoscore-c.svg", + "name" : "Eco-Score", "title" : "Eco-Score C - Moderate environmental impact", "type" : "grade" }, @@ -1571,13 +1572,17 @@ } } ], - "evaluation" : "", + "evaluation" : "average", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/moderate.svg", - "title" : "Fat in moderate quantity (8.5%)" + "name" : "Fat", + "title" : "Fat in moderate quantity (8.5%)", + "type" : "percentage", + "value" : 8.5 }, "topics" : [ "health" @@ -1613,13 +1618,17 @@ } } ], - "evaluation" : "", + "evaluation" : "good", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/low.svg", - "title" : "Salt in low quantity (0.0502%)" + "name" : "Salt", + "title" : "Salt in low quantity (0.0502%)", + "type" : "percentage", + "value" : 0.0502 }, "topics" : [ "health" @@ -1645,13 +1654,17 @@ } } ], - "evaluation" : "", + "evaluation" : "bad", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/high.svg", - "title" : "Saturated fat in high quantity (5.6%)" + "name" : "Saturated fat", + "title" : "Saturated fat in high quantity (5.6%)", + "type" : "percentage", + "value" : 5.6 }, "topics" : [ "health" @@ -1677,13 +1690,17 @@ } } ], - "evaluation" : "", + "evaluation" : "average", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/moderate.svg", - "title" : "Sugars in moderate quantity (12.5%)" + "name" : "Sugars", + "title" : "Sugars in moderate quantity (12.5%)", + "type" : "percentage", + "value" : 12.5 }, "topics" : [ "health" diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-fields-attribute-groups-all-knowledge-panels.json b/tests/integration/expected_test_results/api_v2_product_read/get-fields-attribute-groups-all-knowledge-panels.json index bd6e131db2292..e4c525b64071b 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-fields-attribute-groups-all-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-fields-attribute-groups-all-knowledge-panels.json @@ -1540,6 +1540,7 @@ "title_element" : { "grade" : "c", "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/dist/ecoscore-c.svg", + "name" : "Eco-Score", "title" : "Eco-Score C - Moderate environmental impact", "type" : "grade" }, @@ -2227,13 +2228,17 @@ } } ], - "evaluation" : "", + "evaluation" : "average", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/moderate.svg", - "title" : "Fat in moderate quantity (8.5%)" + "name" : "Fat", + "title" : "Fat in moderate quantity (8.5%)", + "type" : "percentage", + "value" : 8.5 }, "topics" : [ "health" @@ -2269,13 +2274,17 @@ } } ], - "evaluation" : "", + "evaluation" : "good", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/low.svg", - "title" : "Salt in low quantity (0.0502%)" + "name" : "Salt", + "title" : "Salt in low quantity (0.0502%)", + "type" : "percentage", + "value" : 0.0502 }, "topics" : [ "health" @@ -2301,13 +2310,17 @@ } } ], - "evaluation" : "", + "evaluation" : "bad", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/high.svg", - "title" : "Saturated fat in high quantity (5.6%)" + "name" : "Saturated fat", + "title" : "Saturated fat in high quantity (5.6%)", + "type" : "percentage", + "value" : 5.6 }, "topics" : [ "health" @@ -2333,13 +2346,17 @@ } } ], - "evaluation" : "", + "evaluation" : "average", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/moderate.svg", - "title" : "Sugars in moderate quantity (12.5%)" + "name" : "Sugars", + "title" : "Sugars in moderate quantity (12.5%)", + "type" : "percentage", + "value" : 12.5 }, "topics" : [ "health" diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json index 5c0614da41739..85106b937310e 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_excluded-environment_card.json @@ -310,13 +310,17 @@ } } ], - "evaluation" : "", + "evaluation" : "average", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/moderate.svg", - "title" : "Fat in moderate quantity (8.5%)" + "name" : "Fat", + "title" : "Fat in moderate quantity (8.5%)", + "type" : "percentage", + "value" : 8.5 }, "topics" : [ "health" @@ -352,13 +356,17 @@ } } ], - "evaluation" : "", + "evaluation" : "good", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/low.svg", - "title" : "Salt in low quantity (0.0502%)" + "name" : "Salt", + "title" : "Salt in low quantity (0.0502%)", + "type" : "percentage", + "value" : 0.0502 }, "topics" : [ "health" @@ -384,13 +392,17 @@ } } ], - "evaluation" : "", + "evaluation" : "bad", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/high.svg", - "title" : "Saturated fat in high quantity (5.6%)" + "name" : "Saturated fat", + "title" : "Saturated fat in high quantity (5.6%)", + "type" : "percentage", + "value" : 5.6 }, "topics" : [ "health" @@ -416,13 +428,17 @@ } } ], - "evaluation" : "", + "evaluation" : "average", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/moderate.svg", - "title" : "Sugars in moderate quantity (12.5%)" + "name" : "Sugars", + "title" : "Sugars in moderate quantity (12.5%)", + "type" : "percentage", + "value" : 12.5 }, "topics" : [ "health" diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card-knowledge_panels_excluded-health_card.json b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card-knowledge_panels_excluded-health_card.json index ba8edd1156661..ed4d76c416a43 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card-knowledge_panels_excluded-health_card.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card-knowledge_panels_excluded-health_card.json @@ -185,6 +185,7 @@ "title_element" : { "grade" : "c", "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/dist/ecoscore-c.svg", + "name" : "Eco-Score", "title" : "Eco-Score C - Moderate environmental impact", "type" : "grade" }, diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json index 2813a740cbd76..61c6a778f681a 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json @@ -185,6 +185,7 @@ "title_element" : { "grade" : "c", "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/dist/ecoscore-c.svg", + "name" : "Eco-Score", "title" : "Eco-Score C - Moderate environmental impact", "type" : "grade" }, @@ -842,13 +843,17 @@ } } ], - "evaluation" : "", + "evaluation" : "average", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/moderate.svg", - "title" : "Fat in moderate quantity (8.5%)" + "name" : "Fat", + "title" : "Fat in moderate quantity (8.5%)", + "type" : "percentage", + "value" : 8.5 }, "topics" : [ "health" @@ -884,13 +889,17 @@ } } ], - "evaluation" : "", + "evaluation" : "good", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/low.svg", - "title" : "Salt in low quantity (0.0502%)" + "name" : "Salt", + "title" : "Salt in low quantity (0.0502%)", + "type" : "percentage", + "value" : 0.0502 }, "topics" : [ "health" @@ -916,13 +925,17 @@ } } ], - "evaluation" : "", + "evaluation" : "bad", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/high.svg", - "title" : "Saturated fat in high quantity (5.6%)" + "name" : "Saturated fat", + "title" : "Saturated fat in high quantity (5.6%)", + "type" : "percentage", + "value" : 5.6 }, "topics" : [ "health" @@ -948,13 +961,17 @@ } } ], - "evaluation" : "", + "evaluation" : "average", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/moderate.svg", - "title" : "Sugars in moderate quantity (12.5%)" + "name" : "Sugars", + "title" : "Sugars in moderate quantity (12.5%)", + "type" : "percentage", + "value" : 12.5 }, "topics" : [ "health" diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json index efd8bbd62a89e..45860d65908c9 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels-fr.json @@ -185,6 +185,7 @@ "title_element" : { "grade" : "c", "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/dist/ecoscore-c.svg", + "name" : "Eco-Score", "title" : "Eco-Score C - Impact modéré sur l'environnement", "type" : "grade" }, @@ -872,13 +873,17 @@ } } ], - "evaluation" : "", + "evaluation" : "average", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/moderate.svg", - "title" : "Matières grasses en quantité modérée (8.5%)" + "name" : "Matières grasses", + "title" : "Matières grasses en quantité modérée (8.5%)", + "type" : "percentage", + "value" : 8.5 }, "topics" : [ "health" @@ -914,13 +919,17 @@ } } ], - "evaluation" : "", + "evaluation" : "good", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/low.svg", - "title" : "Sel en faible quantité (0.0502%)" + "name" : "Sel", + "title" : "Sel en faible quantité (0.0502%)", + "type" : "percentage", + "value" : 0.0502 }, "topics" : [ "health" @@ -946,13 +955,17 @@ } } ], - "evaluation" : "", + "evaluation" : "bad", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/high.svg", - "title" : "Acides gras saturés en quantité élevée (5.6%)" + "name" : "Acides gras saturés", + "title" : "Acides gras saturés en quantité élevée (5.6%)", + "type" : "percentage", + "value" : 5.6 }, "topics" : [ "health" @@ -978,13 +991,17 @@ } } ], - "evaluation" : "", + "evaluation" : "average", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/moderate.svg", - "title" : "Sucres en quantité modérée (12.5%)" + "name" : "Sucres", + "title" : "Sucres en quantité modérée (12.5%)", + "type" : "percentage", + "value" : 12.5 }, "topics" : [ "health" diff --git a/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json index 6ef310f246964..83340712e8621 100644 --- a/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v2_product_read/get-knowledge-panels.json @@ -185,6 +185,7 @@ "title_element" : { "grade" : "c", "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/dist/ecoscore-c.svg", + "name" : "Eco-Score", "title" : "Eco-Score C - Moderate environmental impact", "type" : "grade" }, @@ -872,13 +873,17 @@ } } ], - "evaluation" : "", + "evaluation" : "average", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/moderate.svg", - "title" : "Fat in moderate quantity (8.5%)" + "name" : "Fat", + "title" : "Fat in moderate quantity (8.5%)", + "type" : "percentage", + "value" : 8.5 }, "topics" : [ "health" @@ -914,13 +919,17 @@ } } ], - "evaluation" : "", + "evaluation" : "good", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/low.svg", - "title" : "Salt in low quantity (0.0502%)" + "name" : "Salt", + "title" : "Salt in low quantity (0.0502%)", + "type" : "percentage", + "value" : 0.0502 }, "topics" : [ "health" @@ -946,13 +955,17 @@ } } ], - "evaluation" : "", + "evaluation" : "bad", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/high.svg", - "title" : "Saturated fat in high quantity (5.6%)" + "name" : "Saturated fat", + "title" : "Saturated fat in high quantity (5.6%)", + "type" : "percentage", + "value" : 5.6 }, "topics" : [ "health" @@ -978,13 +991,17 @@ } } ], - "evaluation" : "", + "evaluation" : "average", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/moderate.svg", - "title" : "Sugars in moderate quantity (12.5%)" + "name" : "Sugars", + "title" : "Sugars in moderate quantity (12.5%)", + "type" : "percentage", + "value" : 12.5 }, "topics" : [ "health" diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-fields-all-knowledge-panels.json b/tests/integration/expected_test_results/api_v3_product_read/get-fields-all-knowledge-panels.json index d2942dbab9d7a..80763d7fd81c5 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-fields-all-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-fields-all-knowledge-panels.json @@ -879,6 +879,7 @@ "title_element" : { "grade" : "c", "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/dist/ecoscore-c.svg", + "name" : "Eco-Score", "title" : "Eco-Score C - Moderate environmental impact", "type" : "grade" }, diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-fields-attribute-groups-all-knowledge-panels.json b/tests/integration/expected_test_results/api_v3_product_read/get-fields-attribute-groups-all-knowledge-panels.json index c666effcfd87e..70c2a0fe05045 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-fields-attribute-groups-all-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-fields-attribute-groups-all-knowledge-panels.json @@ -1527,6 +1527,7 @@ "title_element" : { "grade" : "c", "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/dist/ecoscore-c.svg", + "name" : "Eco-Score", "title" : "Eco-Score C - Moderate environmental impact", "type" : "grade" }, diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card-knowledge_panels_excluded-health_card.json b/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card-knowledge_panels_excluded-health_card.json index 64ad6e18a3027..1a398d4e82557 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card-knowledge_panels_excluded-health_card.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card-knowledge_panels_excluded-health_card.json @@ -186,6 +186,7 @@ "title_element" : { "grade" : "c", "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/dist/ecoscore-c.svg", + "name" : "Eco-Score", "title" : "Eco-Score C - Moderate environmental impact", "type" : "grade" }, diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json b/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json index 46181d624ef02..fb09d2de473cb 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-fields-knowledge-panels-knowledge-panels_included-health_card-environment_card.json @@ -186,6 +186,7 @@ "title_element" : { "grade" : "c", "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/dist/ecoscore-c.svg", + "name" : "Eco-Score", "title" : "Eco-Score C - Moderate environmental impact", "type" : "grade" }, diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json index 508fb0d1d6eae..bc91ed1cbd7cc 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels-fr.json @@ -186,6 +186,7 @@ "title_element" : { "grade" : "c", "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/dist/ecoscore-c.svg", + "name" : "Eco-Score", "title" : "Eco-Score C - Impact modéré sur l'environnement", "type" : "grade" }, diff --git a/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json index 2428ef11aeee0..eacd14f068bc4 100644 --- a/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json +++ b/tests/integration/expected_test_results/api_v3_product_read/get-knowledge-panels.json @@ -186,6 +186,7 @@ "title_element" : { "grade" : "c", "icon_url" : "http://static.openfoodfacts.localhost/images/attributes/dist/ecoscore-c.svg", + "name" : "Eco-Score", "title" : "Eco-Score C - Moderate environmental impact", "type" : "grade" }, diff --git a/tests/integration/expected_test_results/data_quality_knowledge_panel/data-quality.json b/tests/integration/expected_test_results/data_quality_knowledge_panel/data-quality.json index 8217637e8e151..5bc29410efce8 100644 --- a/tests/integration/expected_test_results/data_quality_knowledge_panel/data-quality.json +++ b/tests/integration/expected_test_results/data_quality_knowledge_panel/data-quality.json @@ -594,13 +594,17 @@ } } ], - "evaluation" : "", + "evaluation" : "bad", + "half_width_on_mobile" : true, "level" : "info", "size" : "small", "title_element" : { "icon_size" : "small", "icon_url" : "http://static.openfoodfacts.localhost/images/misc/high.svg", - "title" : "Salt in high quantity (120%)" + "name" : "Salt", + "title" : "Salt in high quantity (120%)", + "type" : "percentage", + "value" : 120 }, "topics" : [ "health"