feat(db): add similarity lookup queries (ListActiveContextualLikesForUser, GetCurrentSessionVectorForUser)

This commit is contained in:
2026-04-27 20:36:42 -04:00
parent 49871ba06d
commit cb46b3830f
13 changed files with 91 additions and 11 deletions
+11
View File
@@ -8,3 +8,14 @@ VALUES ($1, $2, $3, $4);
UPDATE contextual_likes
SET deleted_at = now()
WHERE user_id = $1 AND track_id = $2 AND deleted_at IS NULL;
-- name: ListActiveContextualLikesForUser :many
-- Returns all the user's active (non-soft-deleted) contextual_likes with
-- non-null vectors. Cardinality is bounded by the user's actual like-while-
-- playing history — typically tens to low hundreds. Used by the engine to
-- compute contextual_match_score for the candidate pool.
SELECT track_id, session_vector
FROM contextual_likes
WHERE user_id = $1
AND deleted_at IS NULL
AND session_vector IS NOT NULL;