feat: feedback-driven recipe discovery (auto-ingest via Spoonacular)
CI / backend (pytest + alembic) (push) Has been cancelled
CI / frontend (build) (push) Has been cancelled

This commit is contained in:
2026-05-24 13:17:39 -07:00
parent 35f736a052
commit 3885d7d0dc
20 changed files with 1962 additions and 9 deletions
+51 -1
View File
@@ -16,6 +16,7 @@ from app.schemas import (
)
from app.security import require_session
from app.services import approval as approval_service
from app.services.feedback_analyzer import FeedbackAnalyzer
from uuid import UUID
from typing import List, Optional
from datetime import datetime, timedelta
@@ -473,4 +474,53 @@ def move_meal_item(
db.commit()
db.refresh(item)
return {"message": "Meal moved", "item": item}
return {"message": "Meal moved", "item": item}
# ── Dashboard badge: newly discovered recipes ─────────────────────────
@router.get("/dashboard/discovered-count")
def discovered_count(db: Session = Depends(get_db)):
"""Return number of recipes discovered in the last 7 days for the current family."""
profile = db.query(FamilyProfile).first()
if not profile:
raise HTTPException(status_code=404, detail="Family profile not found")
since = datetime.utcnow() - timedelta(days=7)
count = (
db.query(Recipe)
.filter(
Recipe.family_profile_id == profile.id,
Recipe.external_source.isnot(None),
Recipe.created_at >= since,
)
.count()
)
return {"discovered_count": count}
@router.get("/dashboard/discovery-insights")
def discovery_insights(db: Session = Depends(get_db)):
"""Return latest feedback analysis and top signals."""
profile = db.query(FamilyProfile).first()
if not profile:
raise HTTPException(status_code=404, detail="Family profile not found")
latest_run = (
db.query(WeeklyRun)
.filter(WeeklyRun.family_id == profile.id)
.order_by(WeeklyRun.week_start_date.desc())
.first()
)
if not latest_run or not latest_run.feedback_analysis:
return {"has_analysis": False}
analysis = latest_run.feedback_analysis
return {
"has_analysis": True,
"confidence": analysis.get("confidence", 0),
"positive_signals": analysis.get("positive_signals", []),
"negative_signals": analysis.get("negative_signals", []),
"top_rated_recipes": analysis.get("top_rated_recipes", []),
}