Files
minstrel/internal/db/dbq/sessions.sql.go
T
bvandeusen 0c7e1b0408 feat(playevents): add Writer with start/end/skipped/synthetic paths
Owns the auto-close-prior step (caps each user at one open row),
spec §6 skip classification rule on play_ended (AND of completion <
0.5 and duration_played < 30s), and skip_events row writes. Synthetic
completed play wires the Subsonic /rest/scrobble?submission=true path
into the same store as native events.
2026-04-26 00:10:02 -04:00

84 lines
2.0 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: sessions.sql
package dbq
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const deleteSession = `-- name: DeleteSession :exec
DELETE FROM sessions WHERE id = $1
`
func (q *Queries) DeleteSession(ctx context.Context, id pgtype.UUID) error {
_, err := q.db.Exec(ctx, deleteSession, id)
return err
}
const deleteSessionByTokenHash = `-- name: DeleteSessionByTokenHash :exec
DELETE FROM sessions WHERE token_hash = $1
`
func (q *Queries) DeleteSessionByTokenHash(ctx context.Context, tokenHash []byte) error {
_, err := q.db.Exec(ctx, deleteSessionByTokenHash, tokenHash)
return err
}
const getSessionByTokenHash = `-- name: GetSessionByTokenHash :one
SELECT id, user_id, token_hash, user_agent, created_at, last_seen_at FROM sessions WHERE token_hash = $1
`
func (q *Queries) GetSessionByTokenHash(ctx context.Context, tokenHash []byte) (Session, error) {
row := q.db.QueryRow(ctx, getSessionByTokenHash, tokenHash)
var i Session
err := row.Scan(
&i.ID,
&i.UserID,
&i.TokenHash,
&i.UserAgent,
&i.CreatedAt,
&i.LastSeenAt,
)
return i, err
}
const insertSession = `-- name: InsertSession :one
INSERT INTO sessions (user_id, token_hash, user_agent)
VALUES ($1, $2, $3)
RETURNING id, user_id, token_hash, user_agent, created_at, last_seen_at
`
type InsertSessionParams struct {
UserID pgtype.UUID
TokenHash []byte
UserAgent string
}
func (q *Queries) InsertSession(ctx context.Context, arg InsertSessionParams) (Session, error) {
row := q.db.QueryRow(ctx, insertSession, arg.UserID, arg.TokenHash, arg.UserAgent)
var i Session
err := row.Scan(
&i.ID,
&i.UserID,
&i.TokenHash,
&i.UserAgent,
&i.CreatedAt,
&i.LastSeenAt,
)
return i, err
}
const touchSessionLastSeen = `-- name: TouchSessionLastSeen :exec
UPDATE sessions SET last_seen_at = now() WHERE id = $1
`
func (q *Queries) TouchSessionLastSeen(ctx context.Context, id pgtype.UUID) error {
_, err := q.db.Exec(ctx, touchSessionLastSeen, id)
return err
}