- ID
- be7923-tag-filtering-cookbook-detail
BE-7923 Add tag-based filtering to Cookbook DETAIL endpoint
- source :: https://hungryroot.atlassian.net/browse/BE-7923
- tags :: Hungryroot API Project
- status :: Development in Progress
Context
Sections previously provided browse-by-category UX ("Breakfast", "Lunch + Dinner", "Snacks").
With sections removed from the API, tag-based filtering on the detail endpoint replaces that grouping.
Pattern already implemented on ~CustomerFavoritesView~ (via ~OccasionBucket~); port to ~CookbookDetailView~.
Work
DONE Add ~tag_id~ param to ~_get_sections_queryset~ — filter items by pairing/product tag
DONE Thread ~tag_id~ through ~_get_cookbooks_queryset~
DONE Override ~get_queryset()~ on ~CookbookDetailView~ to parse and pass ~tag_id~
DONE Update ~@extend_schema~ on ~CookbookDetailView~
DONE Write tests: filtered + unfiltered cases
API
#+begin_src
GET /api/v3/cookbooks/<slug>/?tag_id=<tag-id>
#+end_src
Unfiltered request returns all items (unchanged).
Filtered request returns only pairings/products tagged with ~tag_id~.
Notes
- ~tag_id~ on the detail endpoint filters *items within* the cookbook (not cookbooks by dietary tag)
- That is distinct from ~tag_id~ on the list endpoint (which filters which cookbooks appear)
- Filtering uses ~pairing__tags__id=tag_id OR product__tags__id=tag_id~ on ~CookbookItem~