Rewrites the internal/db/queries comments to rule 32 and regenerates dbq, whose doc comments and embedded SQL carry them. The bugs behind the tiered mixes, the md5 order seed, the score bands and the round-robin arms are restated as the constraint each one enforces; counts from one library and stale cross-references are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
880 B
SQL
25 lines
880 B
SQL
-- name: WriteAuditLog :exec
|
|
INSERT INTO audit_log (actor_id, target_id, action, metadata)
|
|
VALUES ($1, $2, $3, $4);
|
|
|
|
-- name: ListAuditLog :many
|
|
SELECT * FROM audit_log
|
|
ORDER BY created_at DESC
|
|
LIMIT $1 OFFSET $2;
|
|
|
|
-- name: CountAuditLogByActions :one
|
|
-- System actions carry no actor; system_only narrows to them.
|
|
SELECT count(*)::bigint FROM audit_log
|
|
WHERE action = ANY(sqlc.arg(actions)::text[])
|
|
AND (NOT sqlc.arg(system_only)::boolean OR actor_id IS NULL);
|
|
|
|
-- name: ListAuditLogByActions :many
|
|
-- One page of the given actions, newest first: the duplicates report's
|
|
-- "resolved automatically" activity reads the resolver's merges from
|
|
-- here.
|
|
SELECT * FROM audit_log
|
|
WHERE action = ANY(sqlc.arg(actions)::text[])
|
|
AND (NOT sqlc.arg(system_only)::boolean OR actor_id IS NULL)
|
|
ORDER BY created_at DESC, id
|
|
LIMIT sqlc.arg(page_limit) OFFSET sqlc.arg(page_offset);
|