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

Conversation

benbenben2
Copy link
Collaborator

What

Bug reported on Slack
Sometimes the unit test 'all identical values and above 1 in the nutrition table 2' in dataqualityfood.t fails.

It happens because the array "@major_nutriments_values" (see Ingredients.pm) can have values in random order. Sometimes the first value is "0.8" and since we have the condition "@major_nutriments_values[0] > 1" facet is not raised. And test fails.

See the code for suggested solution

@benbenben2 benbenben2 self-assigned this Jan 30, 2024
@benbenben2 benbenben2 requested a review from a team as a code owner January 30, 2024 21:45
@github-actions github-actions bot added the 🧽 Data quality https://wiki.openfoodfacts.org/Quality label Jan 30, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (55a9b22) 49.54% compared to head (7b817f1) 49.54%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9722   +/-   ##
=======================================
  Coverage   49.54%   49.54%           
=======================================
  Files          67       67           
  Lines       20650    20650           
  Branches     4980     4980           
=======================================
  Hits        10231    10231           
  Misses       9131     9131           
  Partials     1288     1288           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@stephanegigandet stephanegigandet left a comment

Choose a reason for hiding this comment

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

In addition, I think you should add a sort in there:

foreach my $nid (keys %{$product_ref->{nutriments}}) {

->

foreach my $nid (sort keys %{$product_ref->{nutriments}}) {

So that we always go in the same order.

($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.

Copy link

sonarcloud bot commented Jan 31, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link
Contributor

@stephanegigandet stephanegigandet left a comment

Choose a reason for hiding this comment

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

Thanks!

@stephanegigandet stephanegigandet merged commit dc04d18 into main Feb 1, 2024
12 checks passed
@stephanegigandet stephanegigandet deleted the fix_dq_facet_all_values_identical branch February 1, 2024 13:51
john-gom pushed a commit that referenced this pull request May 24, 2024
* fix_dq_facet_all_values_identical

* apply sugestions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧽 Data quality https://wiki.openfoodfacts.org/Quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants