Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix_dq_facet_all_values_identical #9722

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/ProductOpener/DataQualityFood.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1164,21 +1164,25 @@ sub check_nutrition_data ($product_ref) {
}
# raise error if
# all values are identical
# and values (check first value only) are above 1 (see issue #9572)
# OR
# all values but one - because sodium and salt can be automatically calculated one depending on the value of the other - are identical
# and values (check first value only) are above 1 (see issue #9572)
# and values (check salt (should not check sodium which could be lower)) are above 1 (see issue #9572)
# and at least 4 values are input by contributors (see issue #9572)
if (
(
($nutriments_values_occurences_max_value == scalar @major_nutriments_values)
(
$nutriments_values_occurences_max_value == scalar @major_nutriments_values
and (@major_nutriments_values[0] > 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
and (@major_nutriments_values[0] > 1)
and ($major_nutriments_values[0] > 1)

This currently causes a warning in the main branch:

Scalar value @major_nutriments_values[0] better written as $major_nutriments_values[0] at /opt/product-opener/lib/ProductOpener/DataQualityFood.pm line 1171.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

)
or (
($nutriments_values_occurences_max_value >= scalar @major_nutriments_values - 1)
and ( (defined $nutriments_values{'salt_100g'})
and ($nutriments_values{'sodium_100g'})
and ($nutriments_values{'salt_100g'} != $nutriments_values{'sodium_100g'}))
and (defined $nutriments_values{'sodium_100g'})
and ($nutriments_values{'salt_100g'} != $nutriments_values{'sodium_100g'})
and ($nutriments_values{'salt_100g'} > 1))
)
)
and (@major_nutriments_values[0] > 1)
and (scalar @major_nutriments_values > 3)
)
{
Expand Down
Loading