feat: the library's albums go on the wanted list as held, once; after that the list is the truth (M502 #5567)
release / govulncheck (push) Successful in 16s
release / web (push) Successful in 1m24s
release / go (push) Successful in 1m44s
release / integration (push) Successful in 5m19s
release / android (push) Successful in 5m31s
release / Build signed APK (releases and dev) (push) Successful in 5m35s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 25s
release / Verify release artifacts (tag releases only) (push) Skipped
release / govulncheck (push) Successful in 16s
release / web (push) Successful in 1m24s
release / go (push) Successful in 1m44s
release / integration (push) Successful in 5m19s
release / android (push) Successful in 5m31s
release / Build signed APK (releases and dev) (push) Successful in 5m35s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 25s
release / Verify release artifacts (tag releases only) (push) Skipped
A one-time job in the wanted worker lists every album in the library as a held want, one per release group, with a record that it happened (acquisition_settings.library_listed_at). Albums whose tags name only a release are named on MusicBrainz first, 120 a pass; what nothing names is counted and shown on the Held tab. Re-acquisition now wants back only albums on the list. Taking a held album off the list leaves its files, and it is never fetched back; albums put in the library folder by hand afterwards are not added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -69,11 +69,23 @@ func lostAlbum(t *testing.T, pool *pgxpool.Pool, title, release, group string) p
|
||||
return al.ID
|
||||
}
|
||||
|
||||
// #5241: an album is wanted by its release group, never its release id. A
|
||||
// tag-supplied group is used as is; otherwise MusicBrainz names it and the
|
||||
// answer is cached onto the album; an album MusicBrainz cannot name is
|
||||
// skipped and tried again next pass.
|
||||
func TestSweep_WantsAlbumsByReleaseGroup_Integration(t *testing.T) {
|
||||
// heldWant puts an album on the wanted list, held since ago.
|
||||
func heldWant(t *testing.T, pool *pgxpool.Pool, group string, album pgtype.UUID, ago string) {
|
||||
t.Helper()
|
||||
if _, err := pool.Exec(context.Background(), `
|
||||
INSERT INTO wants (release_group_mbid, artist_mbid, artist_name, title, reason, album_id, fulfilled_at)
|
||||
VALUES ($1, 'a', 'A', 'T', 'library', $2, now() - $3::interval)`, group, album, ago); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Only an album on the wanted list is fetched back (#5567): one taken off
|
||||
// it, or dropped into the library by hand, is not. An album on the list is
|
||||
// wanted by its release group, never its release id (#5241): a tag-supplied
|
||||
// group is used as is; otherwise MusicBrainz names it and the answer is
|
||||
// cached onto the album; an album MusicBrainz cannot name is skipped and
|
||||
// tried again next pass.
|
||||
func TestSweep_WantsBackOnlyAlbumsOnTheList_Integration(t *testing.T) {
|
||||
pool := newSweepPool(t)
|
||||
ctx := context.Background()
|
||||
logger := slog.New(slog.NewTextHandler(io.Discard, nil))
|
||||
@@ -85,7 +97,11 @@ func TestSweep_WantsAlbumsByReleaseGroup_Integration(t *testing.T) {
|
||||
}
|
||||
tagged := lostAlbum(t, pool, "Tagged", "release-tagged", "group-tagged")
|
||||
resolved := lostAlbum(t, pool, "Resolved", "release-resolved", "")
|
||||
_ = lostAlbum(t, pool, "Unknown", "release-unknown", "")
|
||||
unknown := lostAlbum(t, pool, "Unknown", "release-unknown", "")
|
||||
_ = lostAlbum(t, pool, "Off The List", "release-off", "group-off")
|
||||
heldWant(t, pool, "group-tagged", tagged, "3 days")
|
||||
heldWant(t, pool, "group-resolved", resolved, "3 days")
|
||||
heldWant(t, pool, "group-unknown", unknown, "3 days")
|
||||
|
||||
s := NewSweeper(pool, settings, logger)
|
||||
asked := map[string]int{}
|
||||
@@ -112,8 +128,14 @@ func TestSweep_WantsAlbumsByReleaseGroup_Integration(t *testing.T) {
|
||||
}
|
||||
wantFor("group-tagged", tagged)
|
||||
wantFor("group-resolved", resolved)
|
||||
if asked["release-tagged"] != 0 {
|
||||
t.Error("MusicBrainz asked about an album whose tags named its group")
|
||||
if w, _ := q.GetWantByReleaseGroup(ctx, "group-unknown"); !w.FulfilledAt.Valid {
|
||||
t.Error("an album MusicBrainz cannot name was reopened under the wrong group")
|
||||
}
|
||||
if _, err := q.GetWantByReleaseGroup(ctx, "group-off"); err == nil {
|
||||
t.Error("an album not on the list was wanted back")
|
||||
}
|
||||
if asked["release-tagged"] != 0 || asked["release-off"] != 0 {
|
||||
t.Errorf("MusicBrainz asked %v: not about a tagged album, nor one off the list", asked)
|
||||
}
|
||||
var cached *string
|
||||
if err := pool.QueryRow(ctx, "SELECT release_group_mbid FROM albums WHERE id = $1", resolved).Scan(&cached); err != nil {
|
||||
@@ -122,13 +144,6 @@ func TestSweep_WantsAlbumsByReleaseGroup_Integration(t *testing.T) {
|
||||
if cached == nil || *cached != "group-resolved" {
|
||||
t.Errorf("resolved group not cached on the album: %v", cached)
|
||||
}
|
||||
var n int
|
||||
if err := pool.QueryRow(ctx, "SELECT count(*) FROM wants").Scan(&n); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if n != 2 {
|
||||
t.Errorf("%d wants, want 2: the unresolvable album is skipped", n)
|
||||
}
|
||||
|
||||
// The next pass finds both already wanted and asks nothing new.
|
||||
asked = map[string]int{}
|
||||
|
||||
Reference in New Issue
Block a user