Skip to content

Commit

Permalink
fix: delete fields after removing ingredients (#8943)
Browse files Browse the repository at this point in the history
  • Loading branch information
benbenben2 authored Sep 7, 2023
1 parent a96392b commit aea40ca
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/ProductOpener/Ingredients.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2470,7 +2470,8 @@ sub compute_ingredients_tags ($product_ref) {
remove_fields(
$product_ref,
[
"ingredients_tags, ingredients_original_tags", "ingredients_n",
"ingredients_hierarchy", "ingredients_tags",
"ingredients_original_tags", "ingredients_n",
"known_ingredients_n", "unknown_ingredients_n",
"ingredients_n_tags", "ingredients_with_specified_percent_n",
"ingredients_with_unspecified_percent_n", "ingredients_with_specified_percent_sum",
Expand Down Expand Up @@ -2629,6 +2630,24 @@ sub extract_ingredients_from_text ($product_ref) {
estimate_nutriscore_fruits_vegetables_nuts_value_from_ingredients($product_ref);

}
else {
remove_fields(
$product_ref,
[
# assign_ciqual_codes - may have been introduced in previous version
"ingredients_without_ciqual_codes",
"ingredients_without_ciqual_codes_n",
]
);
remove_fields(
$product_ref->{nutriments},
[
# estimate_nutriscore_fruits_vegetables_nuts_value_from_ingredients - may have been introduced in previous version
"fruits-vegetables-nuts-estimate-from-ingredients_100g",
"fruits-vegetables-nuts-estimate-from-ingredients_serving",
]
);
}

# Keep the nested list of sub-ingredients, but also copy the sub-ingredients at the end for apps
# that expect a flat list of ingredients
Expand Down

0 comments on commit aea40ca

Please sign in to comment.