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: petfood-nutrition-facts #11188

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Conversation

benbenben2
Copy link
Collaborator

What

Based on EU regulations:
https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX%3A02009R0767-20181226&qid=1734788661215

Nutrition for pet food products is somewhat different than for human food.

There are 3 types of nutriments in pet food nutrition facts

  • analytical constituents -> always in %
  • nutritional additives -> in mg/kg or UI/kg (i.e. not per 100g)
  • zootechnical additives -> in mg/kg

Suggested solution is to use existing nutrition tables as defined in Food.pm (see %nutriments_tables) but split into 2 off_ and opff_.
A few if petfood ... else ... have been introduced. Another option might have been to make it more generic and use setup in ProductsFeatures, but that would have been more complex.

There might be future minor improvements (for the future) such as:

  • vitamin for pet food is in UI and not mg (for now contributors can change)
  • iron II sulphate monohydrate and iron might be used interchangably for pet food. i.e. iron for pet food might not be same as iron for food.
  • crude-protein for pet food might or might not be identical to protein for food. Same for crude-fibre and fibre

Since the nutriments not given in % are given in mg/kg, nutriments suffix can be _1kg and not only _100g (see screenshot of the API below). Also compute_nutrition_data_per_100g_and_per_serving is renamed compute_nutrition_data_per_xxg_and_per_serving,

Fixes:

  • fixed bug pet_food -> petfood (x2)
  • fixed warning in API.pm

comment:
There is a bit of confusion in variables naming because product_type is used for both
- flavor product type (petfood, food, beauty, products)
- nutrition fact quantity/measurement type like in foreach my $product_type ("", "_prepared") {

Screenshot

BEFORE
Screenshot_20250103_234833

AFTER
Screenshot_20250103_234753
Screenshot_20250103_234951
Screenshot_20250103_234911

Related issue(s) and discussion

  • Fixes #-none-

@benbenben2 benbenben2 self-assigned this Jan 3, 2025
@benbenben2 benbenben2 requested a review from a team as a code owner January 3, 2025 23:37
@github-actions github-actions bot added API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) 🧬 Taxonomies https://wiki.openfoodfacts.org/Global_taxonomies ✏️ Editing Data import 🐾 Open Pet Food Facts Our pet food analysis project https://world.openpetfoodfacts.org 🧪 tests 🏭 Producers Platform https://wiki.openfoodfacts.org/Platform_for_producers Food.pm Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. Display Products update all products exports 🧪 unit tests 🚦 Nutri-Score multilingual products 🌐 Translations labels Jan 3, 2025
@codecov-commenter
Copy link

codecov-commenter commented Jan 4, 2025

Codecov Report

Attention: Patch coverage is 14.81481% with 23 lines in your changes missing coverage. Please review.

Project coverage is 49.14%. Comparing base (765d796) to head (c12efba).
Report is 8 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
lib/ProductOpener/Display.pm 0.00% 18 Missing ⚠️
lib/ProductOpener/Food.pm 0.00% 3 Missing and 1 partial ⚠️
lib/ProductOpener/API.pm 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11188      +/-   ##
==========================================
- Coverage   49.18%   49.14%   -0.04%     
==========================================
  Files          78       78              
  Lines       22389    22404      +15     
  Branches     5371     5378       +7     
==========================================
  Hits        11011    11011              
- Misses      10020    10034      +14     
- Partials     1358     1359       +1     

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

@github-actions github-actions bot added the export label Jan 4, 2025
@benbenben2
Copy link
Collaborator Author

/update_tests_results

@stephanegigandet
Copy link
Contributor

@benbenben2 awesome work! Thank a lot for looking into this!

I'm a bit wary of adding the _1kg suffix. I think an alternative would be to keep the _100g internally, so that we can keep the code closer to the food code. Maybe we could discuss it in the product opener meeting, or in another call?

@github-actions github-actions bot added the 🧴 Open Beauty Facts Our cosmetic analysis project https://world.openbeautyfacts.org label Jan 6, 2025
@github-actions github-actions bot added the 📸 Open Products Facts Our project to increase the lifespan of objects. https://world.openproductsfacts.org label Jan 6, 2025
@benbenben2
Copy link
Collaborator Author

@benbenben2 awesome work! Thank a lot for looking into this!

I'm a bit wary of adding the _1kg suffix. I think an alternative would be to keep the _100g internally, so that we can keep the code closer to the food code. Maybe we could discuss it in the product opener meeting, or in another call?

front for product as well as for edit remains per 1 kg. API is rolled back to be per 100g. There is changes in Food and Display to switch from front to api (divide by 10) and from api to front (multiply by 10), respectively.

function name is rolled back from xxg to 100g

Screenshot_20250106_214034
Screenshot_20250106_214051
Screenshot_20250106_214125

@benbenben2
Copy link
Collaborator Author

/lint

@benbenben2
Copy link
Collaborator Author

/lint

Copy link

sonarqubecloud bot commented Jan 8, 2025

@github-actions github-actions bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) Data import Display ✏️ Editing export exports Food.pm 💥 Merge Conflicts 💥 Merge Conflicts multilingual products 🚦 Nutri-Score 🧴 Open Beauty Facts Our cosmetic analysis project https://world.openbeautyfacts.org 🐾 Open Pet Food Facts Our pet food analysis project https://world.openpetfoodfacts.org 📸 Open Products Facts Our project to increase the lifespan of objects. https://world.openproductsfacts.org 🏭 Producers Platform https://wiki.openfoodfacts.org/Platform_for_producers Products 🧬 Taxonomies https://wiki.openfoodfacts.org/Global_taxonomies Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. 🧪 tests 🌐 Translations 🧪 unit tests update all products
Projects
Status: In progress
Status: In progress
Status: In progress
Status: Todo
Status: In progress
Status: In progress
Development

Successfully merging this pull request may close these issues.

3 participants