-- name: CreateResult :one
INSERT INTO results (
    bet_outcome_id,
    event_id,
    odd_id,
    market_id,
    status,
    score,
    created_at,
    updated_at
) VALUES (
    $1,
    $2,
    $3,
    $4,
    $5,
    $6,
    CURRENT_TIMESTAMP,
    CURRENT_TIMESTAMP
) RETURNING *;

-- name: InsertResult :exec
INSERT INTO results (
    bet_outcome_id,
    event_id,
    odd_id,
    market_id,
    status,
    score,
    full_time_score,
    half_time_score,
    ss,
    created_at,
    updated_at
) VALUES (
    $1,
    $2,
    $3,
    $4,
    $5,
    $6,
    $7,
    $8,
    $9,
    CURRENT_TIMESTAMP,
    CURRENT_TIMESTAMP
);

-- name: GetResultByBetOutcomeID :one
SELECT * FROM results WHERE bet_outcome_id = $1;

-- name: GetPendingBetOutcomes :many
SELECT * FROM bet_outcomes WHERE status = 0 AND expires <= CURRENT_TIMESTAMP;
