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
+21 -1
View File
@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// sqlc v1.27.0
// source: events.sql
package dbq
@@ -11,6 +11,26 @@ import (
"github.com/jackc/pgx/v5/pgtype"
)
const getCurrentSessionVectorForUser = `-- name: GetCurrentSessionVectorForUser :one
SELECT pe.session_vector_at_play
FROM play_events pe
JOIN play_sessions s ON s.id = pe.session_id
WHERE pe.user_id = $1
AND s.ended_at IS NULL
ORDER BY pe.started_at DESC
LIMIT 1
`
// Returns the session_vector_at_play of the user's most recent play_event
// in a still-active (un-timed-out) session. NoRows means no current vector.
// Joined with play_sessions so closed sessions don't leak stale vectors.
func (q *Queries) GetCurrentSessionVectorForUser(ctx context.Context, userID pgtype.UUID) ([]byte, error) {
row := q.db.QueryRow(ctx, getCurrentSessionVectorForUser, userID)
var session_vector_at_play []byte
err := row.Scan(&session_vector_at_play)
return session_vector_at_play, err
}
const getMostRecentPlaySessionForUser = `-- name: GetMostRecentPlaySessionForUser :one
SELECT id, user_id, started_at, ended_at, last_event_at, track_count, client_id FROM play_sessions
WHERE user_id = $1