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: deduce 0 sugar/sat fat to compute nutriscore #7947

Merged
merged 3 commits into from
Jan 10, 2023
Merged

Conversation

alexgarel
Copy link
Member

where fat is 0 we can deduce saturated fat is 0, same for sugar from carbohydrates we use it to compute Nutri-Score

Fixes:

where fat is 0 we can deduce saturated fat is 0, same for sugar from carbohydrates
we use it to compute nutriscore
# we have two special case where we can deduce data
next
if (saturated_fat_0_because_of_fat_0($product_ref, $prepared)
|| sugar_0_because_of_carbohydrates_0($product_ref, $prepared));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will fail if you don't have both saturated_fat and sugars, but you have 1 of carbohydrates == 0 or fat == 0. You will get a Nutri-Score even though you can deduce only one of them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is that ok @stephanegigandet (I added a test, so that should do)

Copy link
Member

@CharlesNepote CharlesNepote left a comment

Choose a reason for hiding this comment

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

I'm not able to review in details, but looks good to me.
I completely agree with this first step.

@sonarcloud
Copy link

sonarcloud bot commented Jan 10, 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

@alexgarel alexgarel merged commit f7769b4 into main Jan 10, 2023
@alexgarel alexgarel deleted the feat-carb-fat-0 branch January 10, 2023 09:55
@teolemon teolemon added 🚦 Nutri-Score and removed 🚦Nutri-Score https://world.openfoodfacts.org/nutriscore labels May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 👀 PRs
Development

Successfully merging this pull request may close these issues.

4 participants