mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-23 10:45:20 -05:00
feat(frontend): ✨ food filter and add back search dialog (#794)
* return ingredients and foods on summary * filter on foods * update search page to TS and comp-api * add additional search fields * feat(frontend): ✨ add back search dialog * update docs * formatting * update sidebar - remove dropdown Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
@@ -3,6 +3,7 @@ from typing import Any
|
||||
|
||||
from sqlalchemy.orm import joinedload
|
||||
|
||||
from mealie.db.models.recipe.ingredient import RecipeIngredient
|
||||
from mealie.db.models.recipe.recipe import RecipeModel
|
||||
from mealie.db.models.recipe.settings import RecipeSettings
|
||||
from mealie.schema.recipe import Recipe
|
||||
@@ -64,7 +65,11 @@ class RecipeDataAccessModel(AccessModel[Recipe, RecipeModel]):
|
||||
def summary(self, group_id, start=0, limit=99999) -> Any:
|
||||
return (
|
||||
self.session.query(RecipeModel)
|
||||
.options(joinedload(RecipeModel.recipe_category), joinedload(RecipeModel.tags))
|
||||
.options(
|
||||
joinedload(RecipeModel.recipe_category),
|
||||
joinedload(RecipeModel.tags),
|
||||
joinedload(RecipeModel.recipe_ingredient).options(joinedload(RecipeIngredient.food)),
|
||||
)
|
||||
.filter(RecipeModel.group_id == group_id)
|
||||
.offset(start)
|
||||
.limit(limit)
|
||||
|
||||
@@ -76,6 +76,8 @@ class RecipeSummary(CamelModel):
|
||||
rating: Optional[int]
|
||||
org_url: Optional[str] = Field(None, alias="orgURL")
|
||||
|
||||
recipe_ingredient: Optional[list[RecipeIngredient]] = []
|
||||
|
||||
date_added: Optional[datetime.date]
|
||||
date_updated: Optional[datetime.datetime]
|
||||
|
||||
|
||||
@@ -60,7 +60,15 @@ class RecipeService(CrudHttpMixins[CreateRecipe, Recipe, Recipe], UserHttpServic
|
||||
|
||||
def get_all(self, start=0, limit=None):
|
||||
items = self.db.recipes.summary(self.user.group_id, start=start, limit=limit)
|
||||
return [RecipeSummary.construct(**x.__dict__) for x in items]
|
||||
|
||||
new_items = []
|
||||
for item in items:
|
||||
# Pydantic/FastAPI can't seem to serialize the ingredient field on thier own.
|
||||
new_item = item.__dict__
|
||||
new_item["recipe_ingredient"] = [x.__dict__ for x in item.recipe_ingredient]
|
||||
new_items.append(new_item)
|
||||
|
||||
return [RecipeSummary.construct(**x) for x in new_items]
|
||||
|
||||
def create_one(self, create_data: Union[Recipe, CreateRecipe]) -> Recipe:
|
||||
create_data = recipe_creation_factory(self.user, name=create_data.name, additional_attrs=create_data.dict())
|
||||
|
||||
Reference in New Issue
Block a user