feat(db): add similarity lookup queries (ListActiveContextualLikesForUser, GetCurrentSessionVectorForUser)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user