Auto-rebuild taste profile on every new listen event

The taste profile is just a weighted average of 512-dim vectors — trivially
cheap even with thousands of tracks. Rebuilding on every listen event keeps
recommendations always up to date.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-22 12:39:32 -06:00
parent 57b6d333e9
commit 23fd0e9804

View File

@@ -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}