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>
This commit is contained in:
2026-11-25 22:02:00 -05:00
co-authored by Claude Opus 5.5
parent 987c2a68fa
commit 14aa3dcd5e
28 changed files with 10 additions and 817 deletions
-6
View File
@@ -205,11 +205,6 @@ LIMIT $1 OFFSET $2;
-- Total album count for the /api/library/albums envelope.
SELECT COUNT(*) FROM albums;
-- name: CountAlbumsByArtist :one
-- Used by request-progress reporting to count how many albums have been
-- ingested for a matched artist while a request is still in flight.
SELECT COUNT(*) FROM albums WHERE artist_id = $1;
-- name: DeleteAlbumIfEmpty :one
-- Deletes the album row only when it has no remaining tracks.
-- Used after a track delete to tidy up orphaned albums. RETURNING gives
@@ -304,7 +299,6 @@ UPDATE albums
updated_at = now()
WHERE id = $1;
-- name: GetAlbumsByIDs :many
-- Batched lookup used by /api/library/sync to hydrate upsert payloads
--. Mirror of GetArtistsByIDs.
-3
View File
@@ -30,9 +30,6 @@ WHERE name ILIKE '%' || $1 || '%'
ORDER BY sort_name, id
LIMIT $2 OFFSET $3;
-- name: ListArtistsAlpha :many
SELECT * FROM artists ORDER BY sort_name, name, id LIMIT $1 OFFSET $2;
-- name: ListArtistsNewest :many
-- Secondary id tiebreaker keeps pagination stable when created_at ties.
SELECT * FROM artists ORDER BY created_at DESC, id DESC LIMIT $1 OFFSET $2;
-5
View File
@@ -2,11 +2,6 @@
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
-11
View File
@@ -59,14 +59,3 @@ UPDATE albums
UPDATE albums
SET cover_art_source = NULL
WHERE id = $1 AND cover_art_source = 'none';
-- name: CountAlbumCoverSources :one
-- Diagnostic for the admin overview: counts by source, including NULL.
-- Returns one row with named tallies.
SELECT
COUNT(*) FILTER (WHERE cover_art_source IS NULL) ::bigint AS untried,
COUNT(*) FILTER (WHERE cover_art_source = 'sidecar') ::bigint AS sidecar,
COUNT(*) FILTER (WHERE cover_art_source = 'embedded')::bigint AS embedded,
COUNT(*) FILTER (WHERE cover_art_source = 'mbcaa') ::bigint AS mbcaa,
COUNT(*) FILTER (WHERE cover_art_source = 'none') ::bigint AS none
FROM albums;
-9
View File
@@ -103,15 +103,6 @@ DELETE FROM duplicate_groups g
OR (SELECT s.started_at FROM duplicate_sweeps s WHERE s.id = g.last_seen_sweep_id)
< (SELECT s.started_at FROM duplicate_sweeps s WHERE s.id = sqlc.arg(sweep_id)));
-- name: CountPendingDuplicateGroups :one
-- Proposals awaiting review. A group left with one member — its other tracks
-- deleted since the sweep — is no proposal at all and is not counted; the next
-- sweep retires it.
SELECT count(*)::bigint
FROM duplicate_groups g
WHERE g.status = 'pending'
AND (SELECT count(*) FROM duplicate_group_members m WHERE m.group_id = g.id) >= 2;
-- name: CountPendingDuplicateGroupsInView :one
-- CountPendingDuplicateGroups narrowed to one view of the report:
-- review what an admin still has to decide: every class but
-7
View File
@@ -13,13 +13,6 @@ SELECT * FROM user_invites
WHERE redeemed_at IS NULL AND expires_at > now()
ORDER BY created_at DESC;
-- name: ListInvitesAll :many
-- Includes redeemed + expired for full audit visibility. Caller
-- supplies a LIMIT to bound the response.
SELECT * FROM user_invites
ORDER BY created_at DESC
LIMIT $1;
-- name: RedeemInvite :execrows
-- Atomic claim: returns rows-affected so the caller can detect
-- already-redeemed / expired tokens (rows=0) versus successful claim
-5
View File
@@ -15,8 +15,3 @@ UPDATE password_resets
WHERE token = $1
AND used_at IS NULL
AND expires_at > now();
-- name: DeleteExpiredPasswordResets :exec
-- Cleanup: drop tokens that have been expired more than 7 days.
-- Not wired in U3; useful to have for a future cron sweep.
DELETE FROM password_resets WHERE expires_at < now() - interval '7 days';
-17
View File
@@ -214,23 +214,6 @@ SELECT COALESCE(
LIMIT 1)
)::uuid AS id;
-- name: PickTopAlbumCoverForArtistByUser :one
-- "Songs like X" cover. Most-played album by user; tie-break by most-recent
-- release. NULL if the artist has no albums or all covers are NULL.
-- Note: albums uses cover_art_path (not cover_path).
SELECT a.cover_art_path
FROM albums a
LEFT JOIN tracks t ON t.album_id = a.id
LEFT JOIN play_events pe
ON pe.track_id = t.id
AND pe.user_id = $1
AND pe.was_skipped = false
WHERE a.artist_id = $2
AND a.cover_art_path IS NOT NULL
GROUP BY a.id, a.release_date, a.cover_art_path
ORDER BY COUNT(pe.id) DESC, a.release_date DESC NULLS LAST, a.id
LIMIT 1;
-- name: DeleteSystemPlaylistsForUser :exec
-- Atomic-replace step. CASCADE on playlist_tracks.playlist_id handles
-- the join rows.
-4
View File
@@ -43,10 +43,6 @@ UPDATE users SET subsonic_password = $2 WHERE id = $1;
-- name: GetUserByID :one
SELECT * FROM users WHERE id = $1;
-- name: ListUsernamesByIDs :many
-- Names a list's people in one round trip.
SELECT id, username FROM users WHERE id = ANY($1::uuid[]);
-- name: SetListenBrainzToken :exec
UPDATE users
SET listenbrainz_token = $2,