feat(nutrition): Refactor Ingredient categories to ManyToMany relationship (issue #984)#2414
Open
pankaj-basnet wants to merge 6 commits into
Open
Conversation
…ns for OFF product categories This provides an intermediate structure to hold multi-tiered category taxonomy lists retrieved from Open Food Facts payloads before database persistence processing occurs.
…for ingredient category
…n script Updated extract_info_from_off to parse the raw 'categories_tags' array returned by the API. Refactored fetch_ingredient_from_off to iterate through extracted values, ensuring related category entities are dynamically resolved using get_or_create logic.
- Add data migration (0038) to preserve existing category associations. - Add _assign_categories helper to Ingredient model. - Add IngredientCategorySerializer to support nested category data. - Optimize querysets using prefetch_related
Contributor
Author
|
it seems 1 other test failed (not the tests for this PR)! File "D:\src\PY\src\wger\wger\nutrition\tests\test_nutrition_plan_info.py", line 47, in test_query_count_independent_of_item_count Ran 350 tests in 50.865s FAILED (failures=1) EDIT: |
pankaj-basnet
force-pushed
the
feat/nutrition--ingredient-categories-984
branch
3 times, most recently
from
July 6, 2026 14:59
2062440 to
78ec8f6
Compare
…t categories lists are parsed, cleaned, and assigned
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description:
This PR refactors the
Ingredientmodel to support multiple categories per ingredient, moving away from a restricted 1:N relationship. This aligns with Open Food Facts data structures.wger/nutrition/api/serializers.pyIngredientCategorySerializerand added toIngredientInfoSerializer.wger/nutrition/api/views.pycategorytoprefetch_relatedto optimize database queries.wger/nutrition/dataclasses.pycategoriesto data cleaning lifecycle.wger/nutrition/extract_info/off.pywger/nutrition/migrations/0038...wger/nutrition/models/ingredient.py_assign_categorieshelper and atomic saving logic.Related Issue(s)
Please check that the PR fulfills these requirements
ruff format && isort .)changes etc.), write a small writeup in
CHANGELOG.mdEDIT: