mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-02 20:15:24 +02:00
feat: Query Filter Builder for Cookbooks and Meal Plans (#4346)
This commit is contained in:
parent
2a9a6fa5e6
commit
b8e62ab8dd
47 changed files with 2043 additions and 440 deletions
|
@ -40,15 +40,22 @@ def create_rule(
|
|||
categories: list[CategoryOut] | None = None,
|
||||
households: list[HouseholdSummary] | None = None,
|
||||
):
|
||||
qf_parts: list[str] = []
|
||||
if tags:
|
||||
qf_parts.append(f'tags.id CONTAINS ALL [{",".join([str(tag.id) for tag in tags])}]')
|
||||
if categories:
|
||||
qf_parts.append(f'recipe_category.id CONTAINS ALL [{",".join([str(cat.id) for cat in categories])}]')
|
||||
if households:
|
||||
qf_parts.append(f'household_id IN [{",".join([str(household.id) for household in households])}]')
|
||||
|
||||
query_filter_string = " AND ".join(qf_parts)
|
||||
return unique_user.repos.group_meal_plan_rules.create(
|
||||
PlanRulesSave(
|
||||
group_id=UUID(unique_user.group_id),
|
||||
household_id=UUID(unique_user.household_id),
|
||||
day=day,
|
||||
entry_type=entry_type,
|
||||
tags=tags or [],
|
||||
categories=categories or [],
|
||||
households=households or [],
|
||||
query_filter_string=query_filter_string,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue