Skip to content

Commit

Permalink
initial support for quality checks and the quality facet - issue #912
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanegigandet committed Nov 6, 2017
1 parent 1510b61 commit e029611
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cgi/product_multilingual.pl
Expand Up @@ -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 ();
Expand Down Expand Up @@ -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";

Expand Down
9 changes: 9 additions & 0 deletions po/common/en.po
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions po/tags/en.po
Expand Up @@ -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"

11 changes: 10 additions & 1 deletion scripts/update_all_products.pl
Expand Up @@ -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
Expand All @@ -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/;
Expand All @@ -56,13 +59,15 @@
my $pretend = '';
my $process_ingredients = '';
my $compute_nutrition_score = '';
my $check_quality = '';

GetOptions ("key=s" => \$key, # string
"fields=s" => \@fields_to_update,
"index" => \$index,
"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");

Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e029611

Please sign in to comment.