fix: a second copy of a track counts once, joining words don't part two titles, and a newer matcher retries an older one's refusals (M502 #5569)
release / govulncheck (push) Successful in 15s
release / web (push) Successful in 1m18s
release / go (push) Successful in 1m35s
release / integration (push) Failing after 5m33s
release / android (push) Successful in 5m47s
release / Build signed APK (releases and dev) (push) Successful in 6m4s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped

The second run's refusals were mostly albums holding a track twice (a
two-track single with three files), which no edition can pair, and
release names that differ only in "+" against "/". Tracks are now read
once per disc, number and title, and "and", "&" and "+" count for nothing
when titles are compared; an edition's own title also counts as the
album's name.

library_album_matches records which matcher version decided each album.
Refusals by an older version are matched again, even after the listing is
done, so an improvement reaches them without a migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-10 17:44:06 -04:00
co-authored by Claude Opus 5.5
parent 80d2fdc3ab
commit bf409d5f3f
8 changed files with 146 additions and 34 deletions
+41
View File
@@ -268,7 +268,48 @@ func TestTrackAgreement(t *testing.T) {
if _, miss := trackAgreement([]libraryTrack{{Title: "Other", LengthMs: 61000}}, edition, true); miss != `no track of its edition is like "Other" (1:01)` {
t.Errorf("unplaced: %q", miss)
}
if !sameTitle("Brain Stew + Jaded", "Brain Stew / Jaded") || sameTitle("+++", "Grind & Hustle") || sameTitle("Blur", "The Best of Blur") {
t.Error("sameTitle: joining words count for nothing, and a title of none is no title")
}
n := int32(1)
copies := tracksToMatch([]dbq.ListAlbumTracksToMatchRow{
{Title: "Song", TrackNumber: &n, DurationMs: 1}, {Title: "song", TrackNumber: &n, DurationMs: 2}, {Title: "Other", TrackNumber: &n}})
if len(copies) != 2 {
t.Errorf("a second copy of a track is read once: %+v", copies)
}
if agrees(3, 4) || !agrees(4, 5) || agrees(0, 0) {
t.Error("agrees: 80% of the album's tracks, and an album has tracks")
}
}
// A refusal by an older matcher is matched again once the matching improves,
// even after the listing is done; a refusal by this one is not.
func TestListLibrary_RetriesAnOlderMatchersRefusals_Integration(t *testing.T) {
pool := newPool(t)
ctx := context.Background()
q := dbq.New(pool)
s := newService(t, pool, newFakeMB(t))
ballad := seedAlbum(t, q, blur, "The Ballad of Darren", "", []string{"The Ballad", "St. Charles Square"})
bootleg := seedAlbum(t, q, blur, "Bootleg", "", []string{"Intro"})
for _, a := range []pgtype.UUID{ballad.ID, bootleg.ID} {
if err := q.RecordAlbumMatch(ctx, dbq.RecordAlbumMatchParams{AlbumID: a, Outcome: "unmatched", Detail: "old", Matcher: 1}); err != nil {
t.Fatal(err)
}
}
if _, err := pool.Exec(ctx, `UPDATE library_album_matches SET matcher = $1 WHERE album_id = $2`, libraryMatcher, bootleg.ID); err != nil {
t.Fatal(err)
}
// The reset leaves the listing done.
if err := s.listLibrary(ctx, &PassResult{}); err != nil {
t.Fatal(err)
}
if outcome, method, _, _ := matchOf(t, pool, ballad.ID); outcome != "listed" || method != matchDiscography {
t.Errorf("the older refusal was decided %s by %s", outcome, method)
}
if _, _, _, detail := matchOf(t, pool, bootleg.ID); detail != "old" {
t.Errorf("this matcher's own refusal was retried: %q", detail)
}
if state, _ := q.GetLibraryListing(ctx); state.LibraryUnlisted != 1 {
t.Errorf("unlisted = %d, want the bootleg alone", state.LibraryUnlisted)
}
}