Coverage for opt/mealie/lib/python3.12/site-packages/mealie/repos/repository_meal_plan_rules.py: 88%
13 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-11-25 17:29 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-11-25 17:29 +0000
1from sqlalchemy import or_, select 1A
3from mealie.db.models.household.mealplan import GroupMealPlanRules 1A
4from mealie.schema.meal_plan.plan_rules import PlanRulesDay, PlanRulesOut, PlanRulesType 1A
6from .repository_generic import HouseholdRepositoryGeneric 1A
9class RepositoryMealPlanRules(HouseholdRepositoryGeneric[PlanRulesOut, GroupMealPlanRules]): 1A
10 def get_rules(self, day: PlanRulesDay, entry_type: PlanRulesType) -> list[PlanRulesOut]: 1A
11 stmt = select(GroupMealPlanRules).filter( 1abcdefghijklmnopqrstuvwxyz
12 or_(
13 GroupMealPlanRules.day == day,
14 GroupMealPlanRules.day.is_(None),
15 GroupMealPlanRules.day == PlanRulesDay.unset.value,
16 ),
17 or_(
18 GroupMealPlanRules.entry_type == entry_type,
19 GroupMealPlanRules.entry_type.is_(None),
20 GroupMealPlanRules.entry_type == PlanRulesType.unset.value,
21 ),
22 )
24 if self.group_id: 24 ↛ 26line 24 didn't jump to line 26 because the condition on line 24 was always true1abcdefghijklmnopqrstuvwxyz
25 stmt = stmt.filter(GroupMealPlanRules.group_id == self.group_id) 1abcdefghijklmnopqrstuvwxyz
26 if self.household_id: 26 ↛ 29line 26 didn't jump to line 29 because the condition on line 26 was always true1abcdefghijklmnopqrstuvwxyz
27 stmt = stmt.filter(GroupMealPlanRules.household_id == self.household_id) 1abcdefghijklmnopqrstuvwxyz
29 rules = self.session.execute(stmt).scalars().all() 1abcdefghijklmnopqrstuvwxyz
31 return [self.schema.model_validate(x) for x in rules] 1abcdefghijklmnopqrstuvwxyz