feat(explore): backfill owned artists' discographies offline post-scan

Enrich owned artists whose discography hasn't been fetched yet in a
bounded, resumable background pass so their wider catalogue is searchable
offline right after a scan, instead of only on first artist-page view.

Keyed off the persistent discog_fetched flag via LEFT JOIN, so already-
enriched artists never reappear and the run is a cheap no-op once every
owned artist is covered. Capped at discogBackfillMaxPerRun per run and
routed through discogSF to avoid double-fetching an artist a concurrent
interactive EnsureArtistDiscography is handling. Invoked on both scan
completion (OnStartup) and OnDomReady to resume a capped/interrupted run.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-24 13:38:26 -04:00
co-authored by Claude Opus 4.8
parent 62d66cd97f
commit 37f75d50e5
3 changed files with 119 additions and 0 deletions
+9
View File
@@ -177,6 +177,15 @@ func (e *Service) PopulateLocalCrossReferencesIfNeeded() {
e.index.PopulateLocalCrossReferences()
}
// BackfillLibraryDiscographies enriches owned artists that have not had
// their discography fetched yet, in the background. Idempotent and
// bounded — the query only returns unenriched artists and each is marked
// discog_fetched on success, so this is cheap (an empty query) once every
// owned artist is covered and safe to call on every scan and launch.
func (e *Service) BackfillLibraryDiscographies() {
go e.index.BackfillLibraryDiscographies(e.ctx)
}
// InvalidateLibrarySync clears the "ready" markers guarding the gated
// library-sync steps so they re-run on the next launch. Call after a
// mutation that changes owned content outside a scan (e.g. removing a