feat(meals): suggest complementary sides
CI / backend (pytest + alembic) (push) Has been cancelled
CI / frontend (build) (push) Has been cancelled

This commit is contained in:
2026-06-29 14:59:30 -07:00
parent 18d7300b57
commit 7f5757094e
12 changed files with 294 additions and 9 deletions
+6 -2
View File
@@ -30,6 +30,10 @@ admin_router = APIRouter(
public_router = APIRouter(prefix="/api/meal-plans", tags=["meal-plans"])
def _components_payload(components: dict | None) -> dict:
return dict(components or {})
def _to_response(week_start, plan_id, items: List[MealPlanItem], result: GenerationResult) -> GenerationResponse:
item_payloads: List[GenerationItem] = []
score_by_recipe = {s.recipe_id: s for s in result.selected}
@@ -41,7 +45,7 @@ def _to_response(week_start, plan_id, items: List[MealPlanItem], result: Generat
day_of_week=it.day_of_week,
estimated_cost=it.estimated_cost or 0,
score=scored.score if scored else 0.0,
components={k: float(v) for k, v in (scored.components.items() if scored else [])},
components=_components_payload(it.components or (scored.components if scored else None)),
)
)
return GenerationResponse(
@@ -135,7 +139,7 @@ def get_plan(plan_id: UUID, db: Session = Depends(get_db)) -> GenerationResponse
day_of_week=it.day_of_week,
estimated_cost=it.estimated_cost or 0,
score=it.score or 0.0,
components={k: float(v) for k, v in (it.components.items() if it.components else [])},
components=_components_payload(it.components),
)
for it in items
],