mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 00:14:00 +00:00
fix: bind matcher source to playlist
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user