feat(server/m7-380): one-shot MBID backfill worker for existing libraries
Adds a boot-time goroutine that walks albums with NULL mbid, re-reads tags from one track per album via dhowden/tag, and persists album + artist MBIDs. Healed albums also get their cover_art_source='none' cleared so the enricher's next batch retries the MBCAA fetch. Caps at 5000 albums per boot to avoid stalling startup on huge libraries. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,20 @@ func (q *Queries) ClearAlbumCover(ctx context.Context, id pgtype.UUID) error {
|
||||
return err
|
||||
}
|
||||
|
||||
const clearAlbumCoverNone = `-- name: ClearAlbumCoverNone :exec
|
||||
UPDATE albums
|
||||
SET cover_art_source = NULL
|
||||
WHERE id = $1 AND cover_art_source = 'none'
|
||||
`
|
||||
|
||||
// M7 #380: when MBID backfill heals an album, clear its 'none' cover_art_source
|
||||
// back to NULL so the enricher's next batch retries the MBCAA fetch.
|
||||
// Idempotent — only updates rows currently stamped 'none'.
|
||||
func (q *Queries) ClearAlbumCoverNone(ctx context.Context, id pgtype.UUID) error {
|
||||
_, err := q.db.Exec(ctx, clearAlbumCoverNone, id)
|
||||
return err
|
||||
}
|
||||
|
||||
const countAlbumCoverSources = `-- name: CountAlbumCoverSources :one
|
||||
SELECT
|
||||
COUNT(*) FILTER (WHERE cover_art_source IS NULL) ::bigint AS untried,
|
||||
|
||||
Reference in New Issue
Block a user