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

fix: use ingredient list if lang != lc to parse ingredients #8855

Merged
merged 4 commits into from
Sep 1, 2023

Conversation

raphael0202
Copy link
Contributor

@raphael0202 raphael0202 commented Aug 15, 2023

Solves #5546.

As we add a new field, many expected results files are updated.
Many changes are added to search expected results files, but most of them don't seem to be due to the changes added in this PR.

@raphael0202 raphael0202 requested a review from a team as a code owner August 15, 2023 15:20
@github-actions github-actions bot added 🥗 Ingredients 🧪 tests 📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels 🥗🔍 Ingredients analysis https://wiki.openfoodfacts.org/Ingredients_Extraction_and_Analysis Display Products labels Aug 15, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #8855 (379ab9c) into main (f7905b8) will increase coverage by 0.02%.
Report is 5 commits behind head on main.
The diff coverage is 92.56%.

@@            Coverage Diff             @@
##             main    #8855      +/-   ##
==========================================
+ Coverage   48.67%   48.70%   +0.02%     
==========================================
  Files         118      118              
  Lines       22044    22060      +16     
  Branches     4899     4901       +2     
==========================================
+ Hits        10730    10744      +14     
- Misses      10010    10011       +1     
- Partials     1304     1305       +1     
Files Changed Coverage Δ
lib/ProductOpener/Display.pm 9.94% <0.00%> (-0.01%) ⬇️
lib/ProductOpener/KnowledgePanels.pm 11.44% <0.00%> (ø)
lib/ProductOpener/Ingredients.pm 91.12% <95.10%> (+0.01%) ⬆️
lib/ProductOpener/Products.pm 42.67% <100.00%> (+0.04%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@raphael0202 raphael0202 changed the title feat: use ingredient list in lang != lc to parse ingredients fix: use ingredient list if lang != lc to parse ingredients Aug 16, 2023
@raphael0202 raphael0202 force-pushed the improve-ingredient-lang-handling branch from 379ab9c to 1c914dc Compare August 16, 2023 13:09
@github-actions github-actions bot added API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) 📚 Documentation Documentation issues improve the project for everyone. 🧪 integration tests labels Aug 16, 2023
@stephanegigandet
Copy link
Contributor

Many changes are added to search expected results files, but most of them don't seem to be due to the changes added in this PR.

Those changes are due to the way we construct the products to be searched on, by calling the API with values like:

	{
		%{dclone(\%default_product_form)},
		(
			code => '200000000039',
			lang => "es",
			product_name => "Vegan Test Snack",
			generic_name => "Tester",
			ingredients_text => "apple, water, palm oil",
			origin => "spain",
			categories => "snacks"
		)
	},

There's a bug in the API, and this results in "ingredients_text" + "ingredients_text_en" to be set with "apple, water, palm oil".

With the existing code, we assume "ingredients_text" is in Spanish (because of the lang set to "es"). With your code, we don't look at ingredients_text and instead see the "ingredients_text_en" and assume it is in English.

@stephanegigandet
Copy link
Contributor

I'll fix the API bug.

@stephanegigandet
Copy link
Contributor

Could you add a couple of tests cases specifically for this new feature?

@stephanegigandet
Copy link
Contributor

@raphael0202 This should fix the test differences in search: #8877

@github-actions github-actions bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Aug 28, 2023
@sonarcloud
Copy link

sonarcloud bot commented Aug 31, 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 to me

@stephanegigandet stephanegigandet merged commit bda3567 into main Sep 1, 2023
14 checks passed
@stephanegigandet stephanegigandet deleted the improve-ingredient-lang-handling branch September 1, 2023 09:53
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…) Display 📚 Documentation Documentation issues improve the project for everyone. 🥗🔍 Ingredients analysis https://wiki.openfoodfacts.org/Ingredients_Extraction_and_Analysis 🥗 Ingredients 🧪 integration tests 📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels 💥 Merge Conflicts 💥 Merge Conflicts Products 🧪 tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants