From 82b3533ea6c9b5b523cc64840f5fa2c2062c0696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Wed, 18 Dec 2024 12:50:08 +0100 Subject: [PATCH] eco -> green --- .../attributes/src/green-score-a-plus.svg | 606 ++++++++++ html/images/attributes/src/green-score-a.svg | 1014 +++++++++++++++++ html/images/attributes/src/green-score-b.svg | 907 +++++++++++++++ html/images/attributes/src/green-score-c.svg | 907 +++++++++++++++ html/images/attributes/src/green-score-d.svg | 907 +++++++++++++++ html/images/attributes/src/green-score-e.svg | 924 +++++++++++++++ html/images/attributes/src/green-score-f.svg | 135 +++ .../src/green-score-not-applicable.svg | 986 ++++++++++++++++ .../attributes/src/green-score-unknown.svg | 907 +++++++++++++++ lib/ProductOpener/Attributes.pm | 7 + lib/ProductOpener/Display.pm | 8 + lib/ProductOpener/KnowledgePanels.pm | 7 + ...environmental_score_not_applicable.tt.json | 2 +- .../environmental_score_unknown.tt.json | 2 +- 14 files changed, 7317 insertions(+), 2 deletions(-) create mode 100644 html/images/attributes/src/green-score-a-plus.svg create mode 100644 html/images/attributes/src/green-score-a.svg create mode 100644 html/images/attributes/src/green-score-b.svg create mode 100644 html/images/attributes/src/green-score-c.svg create mode 100644 html/images/attributes/src/green-score-d.svg create mode 100644 html/images/attributes/src/green-score-e.svg create mode 100644 html/images/attributes/src/green-score-f.svg create mode 100644 html/images/attributes/src/green-score-not-applicable.svg create mode 100644 html/images/attributes/src/green-score-unknown.svg diff --git a/html/images/attributes/src/green-score-a-plus.svg b/html/images/attributes/src/green-score-a-plus.svg new file mode 100644 index 0000000000000..528836531f172 --- /dev/null +++ b/html/images/attributes/src/green-score-a-plus.svg @@ -0,0 +1,606 @@ + + diff --git a/html/images/attributes/src/green-score-a.svg b/html/images/attributes/src/green-score-a.svg new file mode 100644 index 0000000000000..2288ae674ef55 --- /dev/null +++ b/html/images/attributes/src/green-score-a.svg @@ -0,0 +1,1014 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/html/images/attributes/src/green-score-b.svg b/html/images/attributes/src/green-score-b.svg new file mode 100644 index 0000000000000..65b748a610c1a --- /dev/null +++ b/html/images/attributes/src/green-score-b.svg @@ -0,0 +1,907 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/html/images/attributes/src/green-score-c.svg b/html/images/attributes/src/green-score-c.svg new file mode 100644 index 0000000000000..f25a8dfe85781 --- /dev/null +++ b/html/images/attributes/src/green-score-c.svg @@ -0,0 +1,907 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/html/images/attributes/src/green-score-d.svg b/html/images/attributes/src/green-score-d.svg new file mode 100644 index 0000000000000..8752eb8022f83 --- /dev/null +++ b/html/images/attributes/src/green-score-d.svg @@ -0,0 +1,907 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/html/images/attributes/src/green-score-e.svg b/html/images/attributes/src/green-score-e.svg new file mode 100644 index 0000000000000..a29fd16b97e19 --- /dev/null +++ b/html/images/attributes/src/green-score-e.svg @@ -0,0 +1,924 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/html/images/attributes/src/green-score-f.svg b/html/images/attributes/src/green-score-f.svg new file mode 100644 index 0000000000000..b056a42041489 --- /dev/null +++ b/html/images/attributes/src/green-score-f.svg @@ -0,0 +1,135 @@ + + diff --git a/html/images/attributes/src/green-score-not-applicable.svg b/html/images/attributes/src/green-score-not-applicable.svg new file mode 100644 index 0000000000000..807a0db18a85a --- /dev/null +++ b/html/images/attributes/src/green-score-not-applicable.svg @@ -0,0 +1,986 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/html/images/attributes/src/green-score-unknown.svg b/html/images/attributes/src/green-score-unknown.svg new file mode 100644 index 0000000000000..50b5178792b5f --- /dev/null +++ b/html/images/attributes/src/green-score-unknown.svg @@ -0,0 +1,907 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/ProductOpener/Attributes.pm b/lib/ProductOpener/Attributes.pm index 83850fb16d226..3c8a8df96071d 100644 --- a/lib/ProductOpener/Attributes.pm +++ b/lib/ProductOpener/Attributes.pm @@ -657,6 +657,13 @@ sub compute_attribute_environmental_score ($product_ref, $target_lc, $target_cc) # id "ecoscore" for the attribute. my $attribute_id = "ecoscore"; + # 2024/12: If we do not have yet environmental_score_data, we use ecoscore_data + # (or possibly for older revisions) + # TBD: remove this code once all products have been updated (but we won't show the score for old revisions) + if ((not defined $product_ref->{environmental_score_data}) and (defined $product_ref->{ecoscore_data})) { + $product_ref->{environmental_score_data} = $product_ref->{ecoscore_data}; + } + my $attribute_ref = initialize_attribute($attribute_id, $target_lc); if ( (defined $product_ref->{environmental_score_data}) diff --git a/lib/ProductOpener/Display.pm b/lib/ProductOpener/Display.pm index 766d3f123835d..da1589497e8c8 100644 --- a/lib/ProductOpener/Display.pm +++ b/lib/ProductOpener/Display.pm @@ -5399,6 +5399,14 @@ sub search_and_display_products ($request_ref, $query_ref, $sort_by, $limit, $pa "environmental_score_data.environmental_score_not_applicable_for_category" => 1, "environmental_score_grade" => 1, "environmental_score_score" => 1, + # 2024-12: get also the ecoscore_data for products that have not been reprocessed yet + # TODO: remove all products have the environmental_data score populated + "ecoscore_data.status" => 1, + ("ecoscore_data.scores." . $request_ref->{cc}) => 1, + ("ecoscore_data.grades." . $request_ref->{cc}) => 1, + "ecoscore_data.environmental_score_not_applicable_for_category" => 1, + "ecoscore_grade" => 1, + "ecoscore_score" => 1, "forest_footprint_data.grade" => 1, "forest_footprint_data.footprint_per_kg" => 1, "ingredients_analysis_tags" => 1, diff --git a/lib/ProductOpener/KnowledgePanels.pm b/lib/ProductOpener/KnowledgePanels.pm index 6d2b79ad7fa64..2a2e4d1c7b905 100644 --- a/lib/ProductOpener/KnowledgePanels.pm +++ b/lib/ProductOpener/KnowledgePanels.pm @@ -555,6 +555,13 @@ sub create_environmental_score_panel ($product_ref, $target_lc, $target_cc, $opt my $cc = $request_ref->{cc}; + # 2024/12: If we do not have yet environmental_score_data, we use ecoscore_data + # (or possibly for older revisions) + # TBD: remove this code once all products have been updated (but we won't show the score for old revisions) + if ((not defined $product_ref->{environmental_score_data}) and (defined $product_ref->{ecoscore_data})) { + $product_ref->{environmental_score_data} = $product_ref->{ecoscore_data}; + } + if ( (defined $product_ref->{environmental_score_data}) and ($product_ref->{environmental_score_data}{status} eq "known")) { diff --git a/templates/api/knowledge-panels/environment/environmental_score/environmental_score_not_applicable.tt.json b/templates/api/knowledge-panels/environment/environmental_score/environmental_score_not_applicable.tt.json index 51370680b69fd..d5803042755ec 100644 --- a/templates/api/knowledge-panels/environment/environmental_score/environmental_score_not_applicable.tt.json +++ b/templates/api/knowledge-panels/environment/environmental_score/environmental_score_not_applicable.tt.json @@ -4,7 +4,7 @@ "environment" ], "title_element": { - "icon_url": "[% static_subdomain %]/images/attributes/dist/environmental-score-not-applicable.svg", + "icon_url": "[% static_subdomain %]/images/attributes/dist/green-score-not-applicable.svg", "title": "[% edq(lang('attribute_environmental_score_not_applicable_title')) %]", "subtitle": "[% panel.subtitle %]", "type": "grade", diff --git a/templates/api/knowledge-panels/environment/environmental_score/environmental_score_unknown.tt.json b/templates/api/knowledge-panels/environment/environmental_score/environmental_score_unknown.tt.json index 3b33086856287..6767369ab42cf 100644 --- a/templates/api/knowledge-panels/environment/environmental_score/environmental_score_unknown.tt.json +++ b/templates/api/knowledge-panels/environment/environmental_score/environmental_score_unknown.tt.json @@ -4,7 +4,7 @@ "environment" ], "title_element": { - "icon_url": "[% static_subdomain %]/images/attributes/dist/environmental-score-unknown.svg", + "icon_url": "[% static_subdomain %]/images/attributes/dist/green-score-unknown.svg", "title": "[% edq(lang('attribute_environmental_score_unknown_title')) %] - [% edq(lang('attribute_environmental_score_unknown_description_short')) %]", "type": "grade", "grade": "unknown",