release / go (push) Successful in 1m50s
release / web (push) Successful in 1m14s
release / govulncheck (push) Successful in 44s
release / integration (push) Successful in 4m11s
release / android (push) Successful in 6m15s
release / Build signed APK (push) Successful in 7m51s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 29s
release / Verify release artifacts (tag releases only) (push) Skipped
getTopSongs ranks the named artist's songs by how often they were played through on this server, then by likes, then in album order, so an artist nobody has played yet still has songs to offer. Missing files and the listener's quarantined songs are left out. savePlayQueue keeps one queue per listener: the songs in order, the one playing, how far into it, and the app that saved it. getPlayQueue gives it back to that listener only; a song no longer in the library drops out. Saving no songs clears it. The queue lives in a new play_queues table, which backups carry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
1.7 KiB
Go
71 lines
1.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: play_queue.sql
|
|
|
|
package dbq
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const deletePlayQueue = `-- name: DeletePlayQueue :exec
|
|
DELETE FROM play_queues WHERE user_id = $1
|
|
`
|
|
|
|
func (q *Queries) DeletePlayQueue(ctx context.Context, userID pgtype.UUID) error {
|
|
_, err := q.db.Exec(ctx, deletePlayQueue, userID)
|
|
return err
|
|
}
|
|
|
|
const getPlayQueue = `-- name: GetPlayQueue :one
|
|
SELECT user_id, track_ids, current_track_id, position_ms, changed_at, changed_by FROM play_queues WHERE user_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetPlayQueue(ctx context.Context, userID pgtype.UUID) (PlayQueue, error) {
|
|
row := q.db.QueryRow(ctx, getPlayQueue, userID)
|
|
var i PlayQueue
|
|
err := row.Scan(
|
|
&i.UserID,
|
|
&i.TrackIds,
|
|
&i.CurrentTrackID,
|
|
&i.PositionMs,
|
|
&i.ChangedAt,
|
|
&i.ChangedBy,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const savePlayQueue = `-- name: SavePlayQueue :exec
|
|
INSERT INTO play_queues (user_id, track_ids, current_track_id, position_ms, changed_at, changed_by)
|
|
VALUES ($1, $2::uuid[], $3, $4, now(), $5)
|
|
ON CONFLICT (user_id) DO UPDATE
|
|
SET track_ids = EXCLUDED.track_ids,
|
|
current_track_id = EXCLUDED.current_track_id,
|
|
position_ms = EXCLUDED.position_ms,
|
|
changed_at = EXCLUDED.changed_at,
|
|
changed_by = EXCLUDED.changed_by
|
|
`
|
|
|
|
type SavePlayQueueParams struct {
|
|
UserID pgtype.UUID
|
|
TrackIds []pgtype.UUID
|
|
CurrentTrackID pgtype.UUID
|
|
PositionMs int64
|
|
ChangedBy string
|
|
}
|
|
|
|
// Replaces the user's saved queue.
|
|
func (q *Queries) SavePlayQueue(ctx context.Context, arg SavePlayQueueParams) error {
|
|
_, err := q.db.Exec(ctx, savePlayQueue,
|
|
arg.UserID,
|
|
arg.TrackIds,
|
|
arg.CurrentTrackID,
|
|
arg.PositionMs,
|
|
arg.ChangedBy,
|
|
)
|
|
return err
|
|
}
|