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:
@@ -6,6 +6,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
|||||||
|
|
||||||
from haunt_fm.db import get_session
|
from haunt_fm.db import get_session
|
||||||
from haunt_fm.services.history_ingest import ingest_listen_event
|
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")
|
router = APIRouter(prefix="/api/history")
|
||||||
|
|
||||||
@@ -38,4 +39,8 @@ async def receive_webhook(payload: WebhookPayload, session: AsyncSession = Depen
|
|||||||
)
|
)
|
||||||
if event is None:
|
if event is None:
|
||||||
return {"ok": True, "duplicate": True}
|
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}
|
return {"ok": True, "track_id": event.track_id, "event_id": event.id}
|
||||||
|
|||||||
Reference in New Issue
Block a user