diff --git a/src/haunt_fm/api/history.py b/src/haunt_fm/api/history.py index 2ce2a08..4ff2a9e 100644 --- a/src/haunt_fm/api/history.py +++ b/src/haunt_fm/api/history.py @@ -6,6 +6,7 @@ from sqlalchemy.ext.asyncio import AsyncSession from haunt_fm.db import get_session from haunt_fm.services.history_ingest import ingest_listen_event +from haunt_fm.services.taste_profile import build_taste_profile router = APIRouter(prefix="/api/history") @@ -38,4 +39,8 @@ async def receive_webhook(payload: WebhookPayload, session: AsyncSession = Depen ) if event is None: return {"ok": True, "duplicate": True} + + # Rebuild taste profile on every new listen event (cheap: just a weighted average) + await build_taste_profile(session) + return {"ok": True, "track_id": event.track_id, "event_id": event.id}