feat: complete task 4 - fix scanner diff.go TypeFilter.suppressed to use centralized filter

This commit is contained in:
2026-07-25 23:12:09 +03:00
parent 41e5e079d4
commit 355a12c6a6
3 changed files with 162 additions and 21 deletions

View File

@@ -2,6 +2,7 @@ package scanner
import (
"naviwatcher/internal/database"
"naviwatcher/internal/musicbrainz"
)
// MissingRelease describes an external release that has no sufficiently similar
@@ -34,23 +35,13 @@ type TypeFilter struct {
// secondary types, matching musicbrainz.FilterReleaseGroups so both the
// cache-miss (store-time) and read-time paths agree.
func (f TypeFilter) suppressed(ext database.ExternalRelease) bool {
if f.IgnoreSingles && (ext.Type == "Single" || hasType(ext.SecondaryTypes, "Single")) {
return true
// Use the centralized filtering logic from musicbrainz package
opts := musicbrainz.FilterOptions{
IgnoreSingles: f.IgnoreSingles,
IgnoreCompilations: f.IgnoreCompilations,
}
if f.IgnoreCompilations && (ext.Type == "Compilation" || hasType(ext.SecondaryTypes, "Compilation")) {
return true
}
return false
}
// hasType reports whether types contains want.
func hasType(types []string, want string) bool {
for _, t := range types {
if t == want {
return true
}
}
return false
filtered := musicbrainz.ApplyTypeToggles([]database.ExternalRelease{ext}, opts)
return len(filtered) == 0
}
// FindMissingReleases compares an artist's external discography against the