From e0296117eae5588e74ceb971f5fef21fe44e6c14 Mon Sep 17 00:00:00 2001 From: Stephane Gigandet Date: Mon, 6 Nov 2017 15:10:48 +0100 Subject: [PATCH] initial support for quality checks and the quality facet - issue #912 --- cgi/product_multilingual.pl | 3 +++ po/common/en.po | 9 +++++++++ po/tags/en.po | 8 ++++++++ scripts/update_all_products.pl | 11 ++++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/cgi/product_multilingual.pl b/cgi/product_multilingual.pl index 4c50b902b75a3..cb0763423f0be 100755 --- a/cgi/product_multilingual.pl +++ b/cgi/product_multilingual.pl @@ -39,6 +39,7 @@ use ProductOpener::Ingredients qw/:all/; use ProductOpener::Images qw/:all/; use ProductOpener::URL qw/:all/; +use ProductOpener::SiteQuality qw/:all/; use Apache2::RequestRec (); use Apache2::Const (); @@ -522,6 +523,8 @@ compute_unknown_nutrients($product_ref); + ProductOpener::SiteQuality::check_quality($product_ref); + $admin and print STDERR "compute_serving_size_date -- done\n"; diff --git a/po/common/en.po b/po/common/en.po index de03000315c12..d16ed3d91b169 100644 --- a/po/common/en.po +++ b/po/common/en.po @@ -399,6 +399,15 @@ msgctxt "debug_s" msgid "debug" msgstr "debug" +msgctxt "quality_p" +msgid "quality" +msgstr "quality" + +msgctxt "quality_s" +msgid "quality" +msgstr "quality" + + msgctxt "delete_comment" msgid "Reason for removal" msgstr "Reason for removal" diff --git a/po/tags/en.po b/po/tags/en.po index 49caf25ecbe10..84798e6129067 100644 --- a/po/tags/en.po +++ b/po/tags/en.po @@ -360,3 +360,11 @@ msgctxt "misc:singular" msgid "misc" msgstr "misc" +msgctxt "quality:plural" +msgid "quality" +msgstr "quality" + +msgctxt "quality:singular" +msgid "quality" +msgstr "quality" + diff --git a/scripts/update_all_products.pl b/scripts/update_all_products.pl index 9aa90868c14cc..0d9c868afc461 100755 --- a/scripts/update_all_products.pl +++ b/scripts/update_all_products.pl @@ -18,6 +18,8 @@ --compute-nutrition-score nutriscore +--check-quality run quality checks + --index specifies that the keywords used by the free text search function (name, brand etc.) need to be reindexed. -- TBD --pretend do not actually update products @@ -39,6 +41,7 @@ use ProductOpener::Food qw/:all/; use ProductOpener::Ingredients qw/:all/; use ProductOpener::Images qw/:all/; +use ProductOpener::SiteQuality qw/:all/; use CGI qw/:cgi :form escapeHTML/; @@ -56,6 +59,7 @@ my $pretend = ''; my $process_ingredients = ''; my $compute_nutrition_score = ''; +my $check_quality = ''; GetOptions ("key=s" => \$key, # string "fields=s" => \@fields_to_update, @@ -63,6 +67,7 @@ "pretend" => \$pretend, "process-ingredients" => \$process_ingredients, "compute-nutrition-score" => \$compute_nutrition_score, + "check-quality" => \$check_quality, ) or die("Error in command line arguments:\n$\nusage"); @@ -94,7 +99,7 @@ die("Unknown fields, check for typos."); } -if ((not $process_ingredients) and (not $compute_nutrition_score) and (scalar @fields_to_update == 0)) { +if ((not $process_ingredients) and (not $compute_nutrition_score) and (not $check_quality) and (scalar @fields_to_update == 0)) { die("Missing fields to update:\n$\nusage"); } @@ -171,6 +176,10 @@ ProductOpener::Food::special_process_product($product_ref); } + if ($check_quality) { + ProductOpener::SiteQuality::check_quality($product_ref); + } + if (not $pretend) { $product_ref->{update_key} = $key; store("$data_root/products/$path/product.sto", $product_ref);