mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 21:13:43 +00:00
feat: enable guarded ranked matcher role
This commit is contained in:
@@ -44,6 +44,40 @@ WHERE state = 'QUEUED' AND playlist = $1 AND expires_at > $2
|
||||
ORDER BY enqueued_at, ticket_id
|
||||
LIMIT $3`
|
||||
|
||||
const RankedParticipantSQL = `SELECT player_id, steam_id
|
||||
FROM identities
|
||||
WHERE player_id = ANY($1)
|
||||
ORDER BY player_id`
|
||||
|
||||
// LoadRankedParticipants resolves the verified identity metadata required by
|
||||
// ranked admission. The caller must compare the returned set with the formed
|
||||
// candidate set; a partial lookup is not a valid ranked roster.
|
||||
func LoadRankedParticipants(ctx context.Context, db *sql.DB, playerIDs []string) ([]domain.RankedParticipant, error) {
|
||||
if db == nil || len(playerIDs) != 6 {
|
||||
return nil, fmt.Errorf("ranked admission requires six players")
|
||||
}
|
||||
rows, err := db.QueryContext(ctx, RankedParticipantSQL, playerIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
participants := make([]domain.RankedParticipant, 0, len(playerIDs))
|
||||
for rows.Next() {
|
||||
var participant domain.RankedParticipant
|
||||
if err := rows.Scan(&participant.PlayerID, &participant.SteamID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
participants = append(participants, participant)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(participants) != len(playerIDs) {
|
||||
return nil, fmt.Errorf("ranked identity metadata is incomplete")
|
||||
}
|
||||
return participants, nil
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
||||
Reference in New Issue
Block a user