feat: complete task 4 - fix scanner diff.go TypeFilter.suppressed to use centralized filter
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user