Skip to content

Commit

Permalink
fix: Make maybe vegan/vegetarian attribute score 50 instead of 20 (#5839
Browse files Browse the repository at this point in the history
)
  • Loading branch information
stephanegigandet authored Oct 6, 2021
1 parent fcacbb0 commit 70ea2e1
Show file tree
Hide file tree
Showing 6 changed files with 540 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/ProductOpener/Attributes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ sub compute_attribute_ingredients_analysis($$$) {
$status = "known";
}
elsif (has_tag($product_ref, "ingredients_analysis", "en:may-contain-$ingredient")) {
$match = 20;
$match = 50;
$analysis_tag = "may-contain-$ingredient";
$status = "known";
}
Expand All @@ -1360,7 +1360,7 @@ sub compute_attribute_ingredients_analysis($$$) {
}
elsif (has_tag($product_ref, "labels", "en:maybe-$analysis")
or has_tag($product_ref, "ingredients_analysis", "en:maybe-$analysis")) {
$match = 20;
$match = 50;
$analysis_tag = "maybe-$analysis";
$status = "known";
}
Expand Down
13 changes: 12 additions & 1 deletion t/attributes.t
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,18 @@ my @tests = (
"fiber_100g" => 5.5,
},
}
],
],

# Maybe vegan: attribute score should be 50
[
'en-maybe-vegan',
{
lc => "en",
categories => "Non-dairy cheeses",
categories_tags => ["en:non-dairy-cheeses"],
ingredients_text => "tapioca starch, palm oil, enzyme",
}
],
);

foreach my $test_ref (@tests) {
Expand Down
4 changes: 2 additions & 2 deletions t/expected_test_results/attributes/en-attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@
"en:egg",
"en:strawberry",
"en:fruit",
"en:berries",
"en:berries",
"en:high-fructose-corn-syrup",
"en:glucose",
"en:fructose",
Expand Down Expand Up @@ -671,7 +671,7 @@
"en:egg",
"en:strawberry",
"en:fruit",
"en:berries",
"en:berries",
"en:high-fructose-corn-syrup",
"en:glucose",
"en:fructose",
Expand Down
Loading

0 comments on commit 70ea2e1

Please sign in to comment.