Public Access
feat(meals): enforce three lower-calorie dinners with media
This commit is contained in:
@@ -37,6 +37,8 @@ class PlannerConfig:
|
||||
total = self.w_savings + self.w_coverage + self.w_pantry + self.w_time + self.w_recency
|
||||
if abs(total - 1.0) > 1e-6:
|
||||
raise ValueError(f"weights must sum to 1.0, got {total}")
|
||||
if self.set_size != 3:
|
||||
raise ValueError("set_size must be 3 dinners per week")
|
||||
|
||||
def merge(self, overrides: "dict[str, Any]") -> "PlannerConfig":
|
||||
"""Return a new PlannerConfig with overrides applied."""
|
||||
|
||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
import logging
|
||||
from typing import Dict, List, Optional, Set
|
||||
from uuid import UUID
|
||||
|
||||
@@ -22,6 +23,7 @@ from app.models import (
|
||||
MealType,
|
||||
NeverSuggest,
|
||||
Recipe,
|
||||
RecipeCatalogStatus,
|
||||
)
|
||||
from app.services.planner.config import DEFAULT, PlannerConfig
|
||||
from app.services.planner.cost import compute_recipe_cost
|
||||
@@ -32,6 +34,9 @@ from app.services.planner.types import GenerationResult
|
||||
from app.services.meal_pairings import components_with_suggested_sides
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _load_match_index(db: Session) -> Dict[UUID, List[dict]]:
|
||||
"""ingredient_id → list of match dicts ordered by confidence DESC."""
|
||||
rows = (
|
||||
@@ -148,7 +153,9 @@ def generate_meal_plan(
|
||||
except (ValueError, TypeError) as exc:
|
||||
logger.warning("Invalid planner_config for family %s: %s", family_id, exc)
|
||||
|
||||
recipes = db.query(Recipe).all()
|
||||
recipes = db.query(Recipe).filter(
|
||||
Recipe.catalog_status == RecipeCatalogStatus.ACTIVE
|
||||
).all()
|
||||
exclude_set = exclude_recipe_ids or set()
|
||||
recipe_dicts = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user