Files
minstrel/internal/db/queries/audit_log.sql
T
bvandeusenandClaude Opus 5.5 14aa3dcd5e chore: remove code left from acquisition and Discover suggestions, and uncalled queries
Nothing reached any of it:
- MusicBrainz search (artists, albums, songs), artist lookups and the
  query escaping they used. The release-group lookups the duplicate
  resolver uses stay.
- Release-group covers, and artist-level tags for artists not in the
  library.
- Nine named queries with no caller (CountTracksByArtist went with the
  previous commit), two of them describing request-progress reporting.

The MusicBrainz client's retry and not-found tests now drive the
release-group lookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:02:00 -05:00

20 lines
780 B
SQL

-- name: WriteAuditLog :exec
INSERT INTO audit_log (actor_id, target_id, action, metadata)
VALUES ($1, $2, $3, $4);
-- 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);