Skip to content

Commit

Permalink
feat(products): new filter by brands_tags (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Aug 20, 2024
1 parent eae407a commit a4f77c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ def get_products_query(filters: ProductFilter | None = None) -> Select[tuple[Pro
Product.labels_tags.contains([filters.labels_tags__contains])
)
filters.labels_tags__contains = None
if filters.brands_tags__contains:
query = query.filter(
Product.brands_tags.contains([filters.brands_tags__contains])
)
filters.brands_tags__contains = None
query = filters.filter(query)
query = filters.sort(query)
return query
Expand Down
1 change: 1 addition & 0 deletions app/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ class ProductFilter(Filter):
product_name__like: Optional[str] | None = None
categories_tags__contains: Optional[str] | None = None # custom (see crud.py)
labels_tags__contains: Optional[str] | None = None # custom (see crud.py)
brands_tags__contains: Optional[str] | None = None # custom (see crud.py)
brands__like: Optional[str] | None = None
nutriscore_grade: Optional[str] | None = None
ecoscore_grade: Optional[str] | None = None
Expand Down

0 comments on commit a4f77c0

Please sign in to comment.