fix: bind matcher source to playlist

This commit is contained in:
Josh Creek
2026-09-01 09:35:00 +01:00
parent d0952adaf9
commit e170bcf0ef
4 changed files with 45 additions and 13 deletions
+5 -5
View File
@@ -40,18 +40,18 @@ RETURNING ticket_id, player_id, playlist, state, client_build, protocol_version,
const QueueCandidateProjectionSQL = `SELECT ticket_id, player_id, playlist, client_build,
protocol_version, enqueued_at
FROM queue_tickets
WHERE state = 'QUEUED' AND expires_at > $1
WHERE state = 'QUEUED' AND playlist = $1 AND expires_at > $2
ORDER BY enqueued_at, ticket_id
LIMIT $2`
LIMIT $3`
// ListQueuedCandidates is an authoritative, expiry-filtered source for the
// matcher projection. It deliberately does not claim rows; CreateProposal is
// the transaction that performs the competing claim with SKIP LOCKED fences.
func ListQueuedCandidates(ctx context.Context, db *sql.DB, now time.Time, limit int) ([]domain.Candidate, error) {
if db == nil || now.IsZero() || limit < 1 || limit > 1000 {
func ListQueuedCandidates(ctx context.Context, db *sql.DB, playlist domain.Playlist, now time.Time, limit int) ([]domain.Candidate, error) {
if db == nil || (playlist != domain.Casual && playlist != domain.Ranked) || now.IsZero() || limit < 1 || limit > 1000 {
return nil, fmt.Errorf("invalid queued candidate arguments")
}
rows, err := db.QueryContext(ctx, QueueCandidateProjectionSQL, now, limit)
rows, err := db.QueryContext(ctx, QueueCandidateProjectionSQL, string(playlist), now, limit)
if err != nil {
return nil, err
}