diff --git a/app/crud.py b/app/crud.py index 4bdcd48f..e61c161e 100644 --- a/app/crud.py +++ b/app/crud.py @@ -191,6 +191,11 @@ def get_products_query(filters: ProductFilter | None = None): Product.categories_tags.contains([filters.categories_tags__contains]) ) filters.categories_tags__contains = None + if filters.labels_tags__contains: + query = query.filter( + Product.categories_tags.contains([filters.labels_tags__contains]) + ) + filters.labels_tags__contains = None query = filters.filter(query) query = filters.sort(query) return query diff --git a/app/schemas.py b/app/schemas.py index e17fe0aa..14c4ee81 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -452,6 +452,7 @@ class ProductFilter(Filter): source: Optional[Flavor] | None = None product_name__like: Optional[str] | None = None categories_tags__contains: Optional[str] | None = None + labels_tags__contains: Optional[str] | None = None brands__like: Optional[str] | None = None nutriscore_grade: Optional[str] | None = None unique_scans_n__gte: Optional[int] | None = None