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

feat: dq_kcal_does_not_match_exclude_more #9339

Merged
merged 7 commits into from
Nov 28, 2023

Conversation

benbenben2
Copy link
Collaborator

What

Need to be reviewed carefully.

  • See comments in the issue
  • see how tests had to be updated (for polyols and erythritol)
  • note that honeys category is under sweeteners and en:energy-value-in-kj-does-not-match-value-computed-from-other-nutrients will be shutdown for those as well

Related issue(s) and discussion

@benbenben2 benbenben2 added 🧽 Data quality https://wiki.openfoodfacts.org/Quality 🧽 Data quality - Nutrition labels Nov 19, 2023
@benbenben2 benbenben2 self-assigned this Nov 19, 2023
@benbenben2 benbenben2 requested a review from a team as a code owner November 19, 2023 09:27
@github-actions github-actions bot added 🧬 Taxonomies https://wiki.openfoodfacts.org/Global_taxonomies categories 🧪 tests labels Nov 19, 2023
@codecov-commenter
Copy link

codecov-commenter commented Nov 19, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ba6739f) 48.18% compared to head (2cd1465) 48.81%.
Report is 19 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9339      +/-   ##
==========================================
+ Coverage   48.18%   48.81%   +0.63%     
==========================================
  Files          65       66       +1     
  Lines       20348    20355       +7     
  Branches     4932     4883      -49     
==========================================
+ Hits         9805     9937     +132     
+ Misses       9288     9161     -127     
- Partials     1255     1257       +2     

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

if (
(
not((defined $ignore_energy_calculated_error) and ($ignore_energy_calculated_error eq 'yes'))
and ( ($product_ref->{nutriments}{"energy-kj_value"} > 55)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment to explain why we have this condition on energy? (so that we know if we revisit it later...)

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.

Instead of disabling the error, I think it would be better to change a bit the condition for the error, in case the energy is low.

(in the part # Compare to specified energy value with a tolerance of 30% + an additiontal tolerance of 5)

That way if the energy is 5, but it should be 1500, we want to have the error raised. We should add a test for that (low energy but lots of fat and sugar for instance)

@benbenben2
Copy link
Collaborator Author

Instead of disabling the error, I think it would be better to change a bit the condition for the error, in case the energy is low.

(in the part # Compare to specified energy value with a tolerance of 30% + an additiontal tolerance of 5)

That way if the energy is 5, but it should be 1500, we want to have the error raised. We should add a test for that (low energy but lots of fat and sugar for instance)

Very good suggestion.

Now, we consider either $specified_energy > 55 or $computed_energy > 55

Now, we can also ignore my previous comment in first message:
see how tests had to be updated (for polyols and erythritol)

Existing test, already covers that case:

# energy does not match nutrients
$product_ref = {
	nutriments => {
		"energy-kj_value" => 5,
		"carbohydrates_value" => 10,
		"fat_value" => 20,
		"proteins_value" => 30,
		"fiber_value" => 2,
	}
};
ProductOpener::DataQuality::check_quality($product_ref);
is($product_ref->{nutriments}{"energy-kj_value_computed"}, 1436);
ok(has_tag($product_ref, 'data_quality', 'en:energy-value-in-kj-does-not-match-value-computed-from-other-nutrients'),
	'energy not matching nutrients')
	or diag explain $product_ref;

Copy link

sonarcloud bot commented Nov 23, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

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.

Looks good, thank you!

@stephanegigandet stephanegigandet merged commit 1d3d352 into main Nov 28, 2023
13 checks passed
@stephanegigandet stephanegigandet deleted the dq_kcal_does_not_match_exclude_more branch November 28, 2023 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
categories 🧽 Data quality - Nutrition 🧽 Data quality https://wiki.openfoodfacts.org/Quality 🧬 Taxonomies https://wiki.openfoodfacts.org/Global_taxonomies Taxonomies 🧪 tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Energy-value-in-kcal-does-not-match-value-computed-from-other-nutrients: exclude more products
3 participants