-- name: GetVote :one
SELECT * FROM votes
WHERE user_id = $1 AND bot_id = $2
ORDER BY voted_at DESC
LIMIT 1;

-- name: ListVotesByBot :many
SELECT * FROM votes
WHERE bot_id = $1
ORDER BY voted_at DESC;

-- name: ListVotesByUser :many
SELECT * FROM votes
WHERE user_id = $1
ORDER BY voted_at DESC;

-- name: CountVotesByBot :one
SELECT count(*) FROM votes
WHERE bot_id = $1;

-- name: CreateVote :one
INSERT INTO votes (user_id, bot_id)
VALUES ($1, $2)
RETURNING *;

-- name: CanVoteAgain :one
SELECT can_vote_again($1, $2);
