-- name: CreateAccessLog :exec
INSERT INTO access_logs(request_id, user_id, ip, user_agent, request_method, request_path, referer, status_code,
                        response_time_ms, started_at, message)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);

-- name: ListAccessLogs :many
SELECT a.*, u.username
FROM access_logs a
         LEFT JOIN sys_users u
                   ON u.id = a.user_id
ORDER BY a.started_at DESC, a.id
LIMIT $1 OFFSET $2;

-- name: CountAccessLogs :one
SELECT COUNT(*)
FROM access_logs;
