feat: unify recipe card sections (#1560)

* removed unused import

* moved categories/tags to new recipe card section

* nuked old frontend sort code
minor refactoring

* bug fixes

* added backend recipes filter for tools

* removed debug log

* removed unusued props

* fixed sort for recipes by tool

* added tests for getting recipes by tool
This commit is contained in:
Michael Genson
2022-08-20 13:59:49 -05:00
committed by GitHub
parent 85448b8a18
commit aaeb162dd5
10 changed files with 231 additions and 232 deletions

View File

@@ -136,6 +136,7 @@ class RepositoryRecipes(RepositoryGeneric[Recipe, RecipeModel]):
load_food=False,
categories: Optional[list[UUID4 | str]] = None,
tags: Optional[list[UUID4 | str]] = None,
tools: Optional[list[UUID4 | str]] = None,
) -> RecipePagination:
q = self.session.query(self.model)
@@ -169,6 +170,14 @@ class RepositoryRecipes(RepositoryGeneric[Recipe, RecipeModel]):
else:
q = q.filter(RecipeModel.tags.any(Tag.slug == tag))
if tools:
for tool in tools:
if isinstance(tool, UUID):
q = q.filter(RecipeModel.tools.any(Tool.id == tool))
else:
q = q.filter(RecipeModel.tools.any(Tool.slug == tool))
q, count, total_pages = self.add_pagination_to_query(q, pagination)
try: