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: added unit for sodium in India #10041

Merged
merged 5 commits into from
Apr 2, 2024

Conversation

himanshisrestha
Copy link
Contributor

What

  • Added unit_in:en: mg key value pair to the nutrients taxonomy
  • Made a new subroutine in Food.pm named get_nutrient_unit

I'vent been able to see effects that the changes made

Related issue(s) and discussion

@github-actions github-actions bot added 🧬 Taxonomies https://wiki.openfoodfacts.org/Global_taxonomies Food.pm multilingual products labels Mar 27, 2024
@stephanegigandet
Copy link
Contributor

I'vent been able to see effects that the changes made

You will see the changes when you edit a product (the default unit should be mg for sodium), and when you view the product page.

Make sure to run "make build_taxonomies" and "make restart" first.

Sodium is automatically converted to salt, so you should put the same unit for salt.

Can you try and see if it works as expected?

Also, could you look in Food.pm, there is a table that defines which nutrients are listed by default on nutrition facts table for specific countries: %nutriments_tables = (

Could you try to add a table for India, so that it shows the nutrients that are printed on food packages in India? (for instance sodium instead of salt, but also added sugars, cholesterol etc.)

@himanshisrestha
Copy link
Contributor Author

Sure.. I'll try and update you soon

@himanshisrestha
Copy link
Contributor Author

himanshisrestha commented Mar 28, 2024

Screenshot 2024-03-28 at 9 52 52 PM

@stephanegigandet , as expected, I'm getting this in the edit product of a mango drink from India whose dummy data and couple of pictures I was adding to test.
Also I've added the table for India as suggested in the %nutriments_tables

@himanshisrestha himanshisrestha marked this pull request as ready for review March 28, 2024 16:44
@himanshisrestha himanshisrestha requested a review from a team as a code owner March 28, 2024 16:44
@@ -87,6 +87,8 @@ BEGIN {

&check_nutriscore_categories_exist_in_taxonomy

&get_nutrient_unit
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be great if you could add a unit test in food.t

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.

It looks good, thank you @himanshisrestha

As @hangy suggests, could you add a simple test for the get_nutrient_unit function in food.t ?

Maybe one test for India to get the unit_in, and one test for a country for which we don't have a unit, to check that we get the default unit.

@himanshisrestha
Copy link
Contributor Author

Sure ... Working on it !!

Copy link

sonarcloud bot commented Apr 1, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 85.71429% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 49.59%. Comparing base (dc04d18) to head (b06f693).
Report is 202 commits behind head on main.

Files Patch % Lines
lib/ProductOpener/Food.pm 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10041      +/-   ##
==========================================
+ Coverage   49.54%   49.59%   +0.04%     
==========================================
  Files          67       70       +3     
  Lines       20650    20940     +290     
  Branches     4980     5021      +41     
==========================================
+ Hits        10231    10385     +154     
- Misses       9131     9264     +133     
- Partials     1288     1291       +3     

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

@alexgarel alexgarel merged commit bf6c22b into openfoodfacts:main Apr 2, 2024
12 checks passed
@himanshisrestha himanshisrestha deleted the fix-sodium-India branch April 4, 2024 17:02
john-gom pushed a commit that referenced this pull request May 24, 2024
- Added unit_in:en: mg key value pair to the nutrients taxonomy
- Made a new subroutine in Food.pm named get_nutrient_unit
- added a test in food.t
- Fixes #10038
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In India, make the default unit for sodium mg instead of g on product edit form on web and mobile app
5 participants