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
-13
View File
@@ -89,19 +89,6 @@ func (q *Queries) CountAlbums(ctx context.Context) (int64, error) {
return count, err
}
const countAlbumsByArtist = `-- name: CountAlbumsByArtist :one
SELECT COUNT(*) FROM albums WHERE artist_id = $1
`
// Used by request-progress reporting to count how many albums have been
// ingested for a matched artist while a request is still in flight.
func (q *Queries) CountAlbumsByArtist(ctx context.Context, artistID pgtype.UUID) (int64, error) {
row := q.db.QueryRow(ctx, countAlbumsByArtist, artistID)
var count int64
err := row.Scan(&count)
return count, err
}
const countAlbumsMatching = `-- name: CountAlbumsMatching :one
SELECT COUNT(*) FROM albums WHERE title ILIKE '%' || $1::text || '%'
`
-40
View File
@@ -218,46 +218,6 @@ func (q *Queries) ListArtists(ctx context.Context) ([]Artist, error) {
return items, nil
}
const listArtistsAlpha = `-- name: ListArtistsAlpha :many
SELECT id, name, sort_name, mbid, created_at, updated_at, artist_thumb_path, artist_fanart_path, artist_art_source, artist_art_sources_version FROM artists ORDER BY sort_name, name, id LIMIT $1 OFFSET $2
`
type ListArtistsAlphaParams struct {
Limit int32
Offset int32
}
func (q *Queries) ListArtistsAlpha(ctx context.Context, arg ListArtistsAlphaParams) ([]Artist, error) {
rows, err := q.db.Query(ctx, listArtistsAlpha, arg.Limit, arg.Offset)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Artist
for rows.Next() {
var i Artist
if err := rows.Scan(
&i.ID,
&i.Name,
&i.SortName,
&i.Mbid,
&i.CreatedAt,
&i.UpdatedAt,
&i.ArtistThumbPath,
&i.ArtistFanartPath,
&i.ArtistArtSource,
&i.ArtistArtSourcesVersion,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listArtistsAlphaWithCovers = `-- name: ListArtistsAlphaWithCovers :many
SELECT artists.id, artists.name, artists.sort_name, artists.mbid, artists.created_at, artists.updated_at, artists.artist_thumb_path, artists.artist_fanart_path, artists.artist_art_source, artists.artist_art_sources_version,
cov.id AS cover_album_id,
-38
View File
@@ -30,44 +30,6 @@ func (q *Queries) CountAuditLogByActions(ctx context.Context, arg CountAuditLogB
return column_1, err
}
const listAuditLog = `-- name: ListAuditLog :many
SELECT id, actor_id, target_id, action, metadata, created_at FROM audit_log
ORDER BY created_at DESC
LIMIT $1 OFFSET $2
`
type ListAuditLogParams struct {
Limit int32
Offset int32
}
func (q *Queries) ListAuditLog(ctx context.Context, arg ListAuditLogParams) ([]AuditLog, error) {
rows, err := q.db.Query(ctx, listAuditLog, arg.Limit, arg.Offset)
if err != nil {
return nil, err
}
defer rows.Close()
var items []AuditLog
for rows.Next() {
var i AuditLog
if err := rows.Scan(
&i.ID,
&i.ActorID,
&i.TargetID,
&i.Action,
&i.Metadata,
&i.CreatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listAuditLogByActions = `-- name: ListAuditLogByActions :many
SELECT id, actor_id, target_id, action, metadata, created_at FROM audit_log
WHERE action = ANY($1::text[])
-33
View File
@@ -39,39 +39,6 @@ func (q *Queries) ClearAlbumCoverNone(ctx context.Context, id pgtype.UUID) error
return err
}
const countAlbumCoverSources = `-- name: CountAlbumCoverSources :one
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
`
type CountAlbumCoverSourcesRow struct {
Untried int64
Sidecar int64
Embedded int64
Mbcaa int64
None int64
}
// Diagnostic for the admin overview: counts by source, including NULL.
// Returns one row with named tallies.
func (q *Queries) CountAlbumCoverSources(ctx context.Context) (CountAlbumCoverSourcesRow, error) {
row := q.db.QueryRow(ctx, countAlbumCoverSources)
var i CountAlbumCoverSourcesRow
err := row.Scan(
&i.Untried,
&i.Sidecar,
&i.Embedded,
&i.Mbcaa,
&i.None,
)
return i, err
}
const getAlbumWithFirstTrackPath = `-- name: GetAlbumWithFirstTrackPath :one
SELECT a.id, a.mbid, a.title, a.cover_art_path, a.cover_art_source,
ar.name AS artist_name,
-17
View File
@@ -27,23 +27,6 @@ func (q *Queries) AddDuplicateGroupMember(ctx context.Context, arg AddDuplicateG
return err
}
const countPendingDuplicateGroups = `-- name: CountPendingDuplicateGroups :one
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
`
// 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.
func (q *Queries) CountPendingDuplicateGroups(ctx context.Context) (int64, error) {
row := q.db.QueryRow(ctx, countPendingDuplicateGroups)
var column_1 int64
err := row.Scan(&column_1)
return column_1, err
}
const countPendingDuplicateGroupsInView = `-- name: CountPendingDuplicateGroupsInView :one
SELECT count(*)::bigint
FROM duplicate_groups g
-36
View File
@@ -109,42 +109,6 @@ func (q *Queries) ListInvitesActive(ctx context.Context) ([]UserInvite, error) {
return items, nil
}
const listInvitesAll = `-- name: ListInvitesAll :many
SELECT token, invited_by, note, created_at, expires_at, redeemed_at, redeemed_by FROM user_invites
ORDER BY created_at DESC
LIMIT $1
`
// Includes redeemed + expired for full audit visibility. Caller
// supplies a LIMIT to bound the response.
func (q *Queries) ListInvitesAll(ctx context.Context, limit int32) ([]UserInvite, error) {
rows, err := q.db.Query(ctx, listInvitesAll, limit)
if err != nil {
return nil, err
}
defer rows.Close()
var items []UserInvite
for rows.Next() {
var i UserInvite
if err := rows.Scan(
&i.Token,
&i.InvitedBy,
&i.Note,
&i.CreatedAt,
&i.ExpiresAt,
&i.RedeemedAt,
&i.RedeemedBy,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const redeemInvite = `-- name: RedeemInvite :execrows
UPDATE user_invites
SET redeemed_at = now(), redeemed_by = $2
-11
View File
@@ -27,17 +27,6 @@ func (q *Queries) CreatePasswordReset(ctx context.Context, arg CreatePasswordRes
return err
}
const deleteExpiredPasswordResets = `-- name: DeleteExpiredPasswordResets :exec
DELETE FROM password_resets WHERE expires_at < now() - interval '7 days'
`
// Cleanup: drop tokens that have been expired more than 7 days.
// Not wired in U3; useful to have for a future cron sweep.
func (q *Queries) DeleteExpiredPasswordResets(ctx context.Context) error {
_, err := q.db.Exec(ctx, deleteExpiredPasswordResets)
return err
}
const getPasswordReset = `-- name: GetPasswordReset :one
SELECT token, user_id, created_at, expires_at, used_at FROM password_resets WHERE token = $1
`
-30
View File
@@ -412,36 +412,6 @@ func (q *Queries) PickSeedArtists(ctx context.Context, userID pgtype.UUID) ([]Pi
return items, nil
}
const pickTopAlbumCoverForArtistByUser = `-- name: PickTopAlbumCoverForArtistByUser :one
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
`
type PickTopAlbumCoverForArtistByUserParams struct {
UserID pgtype.UUID
ArtistID pgtype.UUID
}
// "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).
func (q *Queries) PickTopAlbumCoverForArtistByUser(ctx context.Context, arg PickTopAlbumCoverForArtistByUserParams) (*string, error) {
row := q.db.QueryRow(ctx, pickTopAlbumCoverForArtistByUser, arg.UserID, arg.ArtistID)
var cover_art_path *string
err := row.Scan(&cover_art_path)
return cover_art_path, err
}
const pickTopPlayedTrackForArtistByUser = `-- name: PickTopPlayedTrackForArtistByUser :one
SELECT COALESCE(
(SELECT t.id
-30
View File
@@ -381,36 +381,6 @@ func (q *Queries) ListActiveUsersWithTimezones(ctx context.Context) ([]ListActiv
return items, nil
}
const listUsernamesByIDs = `-- name: ListUsernamesByIDs :many
SELECT id, username FROM users WHERE id = ANY($1::uuid[])
`
type ListUsernamesByIDsRow struct {
ID pgtype.UUID
Username string
}
// Names a list's people in one round trip.
func (q *Queries) ListUsernamesByIDs(ctx context.Context, dollar_1 []pgtype.UUID) ([]ListUsernamesByIDsRow, error) {
rows, err := q.db.Query(ctx, listUsernamesByIDs, dollar_1)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListUsernamesByIDsRow
for rows.Next() {
var i ListUsernamesByIDsRow
if err := rows.Scan(&i.ID, &i.Username); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listUsers = `-- name: ListUsers :many
SELECT id, username, display_name, is_admin,
debug_mode_enabled, created_at