-
-
Notifications
You must be signed in to change notification settings - Fork 400
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: compute percent of vegetables for Nutri-Score after removing water for canned vegetables #9210
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a comment that needs either a change or a comment in the code.
All good for the rest 👍
lib/ProductOpener/Ingredients.pm
Outdated
$water_percent += $sub_ingredients_water_percent; | ||
} | ||
# Keep track of water | ||
elsif (is_a("ingredients", $ingredient_ref->{id}, 'en:water')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why it's an elsif here ?
Are we sure that water never match ? Why not a simple if ? Or, maybe, put it as first condition ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was avoid double counting water if we have something like "flavoured water (water, flavour)", but I'll do it differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment maybe enough then
Also you need a make lint ! |
Codecov Report
@@ Coverage Diff @@
## main #9210 +/- ##
==========================================
+ Coverage 47.95% 47.97% +0.02%
==========================================
Files 65 65
Lines 20223 20231 +8
Branches 4914 4916 +2
==========================================
+ Hits 9697 9706 +9
+ Misses 9271 9270 -1
Partials 1255 1255
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Kudos, SonarCloud Quality Gate passed! |
Some categories of products typically have nutrition facts for the "drained product" (produit égoutté in French). We need to take that into account when computing the % of fruits/vegetables.
We don't record if the nutrition facts is for the drained product, so we take a guess that products in the "canned vegetables" category have nutrition facts for the drained product. There are counter examples, but usually those counter examples have little water anyway.
"IS THE NUTRI-SCORE CALCULATED FOR THE PRODUCT WITH THE COVERING LIQUID?
The nutritional score is calculated using the nutritional data listed on the package for 100 g of the product,
whose nutrients form part of the mandatory nutritional declaration or are included as supplemental
information, in accordance with Article 30 of the INCO regulation no. 1169/2011.
If the covering liquid is taken into account in the mandatory nutritional declaration, the Nutri-Score should
also be calculated for the product + the covering liquid and vice versa. To calculate the percent of “fruits,
vegetables, pulses, nuts and oils », you have to use the same basis as the table of nutritional values. If the
covering liquid is taken into account, the calculation should include it. If the nutritional values do not take
the covering liquid into account, then it should be recalculated without the covering liquid."