-
Notifications
You must be signed in to change notification settings - Fork 0
feat(food): improve food search with diacritic-insensitive and composed multi-word matching #751
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
Conversation
…itics utility - Normalize diacritics in food search queries and database lookups - Add shared removeDiacritics utility and tests - Improves search for names like 'Tapioca doce' regardless of accents
…rtial word matches - Exact name matches appear first in results - Partial matches (by any word) appear below, without duplicates - Improves user experience for multi-word food searches
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
Pull Request Overview
Enhances food search to handle diacritics and multi-word queries by normalizing input and composing exact and partial matches.
- Adds a
removeDiacriticsutility with tests for normalization. - Refactors
fetchFoodsByNameandinternalCachedSearchFoodsto apply normalization and multi-word logic. - Updates prompt file with milestone complexity labeling instructions.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/shared/utils/removeDiacritics.ts | Implements diacritic removal utility. |
| src/shared/utils/removeDiacritics.test.ts | Adds unit tests for the diacritic removal function. |
| src/modules/diet/food/infrastructure/supabaseFoodRepository.ts | Normalizes search terms and composes multi-word searches. |
| .github/prompts/milestone-complexity-labeler.prompt.md | Introduces milestone complexity labeling prompt. |
Comments suppressed due to low confidence (2)
src/modules/diet/food/infrastructure/supabaseFoodRepository.ts:201
- Filtering with
Array.someinsidefilterleads to O(n²) behavior. You can use aSetof exact match IDs (e.g.,const exactIds = new Set(exactMatches.map(f => f.id))) for O(1) lookups and better performance.
partialMatches = partialResults.flat().filter((food) => !exactMatches.some((f) => f.id === food.id))
src/shared/utils/removeDiacritics.test.ts:6
- Consider adding tests for edge cases such as strings with multiple diacritics in different scripts or composed characters (e.g., 'Ångström') to ensure full coverage.
it('removes accents from common pt-BR words', () => {
…glish comments during reviews
This PR enhances the food search functionality to address issues where searches for multi-word or diacritic-containing food names (e.g., "Tapioca doce") returned no results. The main changes are:
removeDiacriticsutility and corresponding tests to support normalization.No breaking changes.
closes #745