Public Access
feat(meals): suggest complementary sides
This commit is contained in:
@@ -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
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user