fix: address code review findings

This commit is contained in:
2026-07-19 19:52:27 +03:00
parent a7803615cd
commit 0bee9b9b27
6 changed files with 138 additions and 31 deletions

View File

@@ -59,10 +59,10 @@ func SyncArtistDiscography(
}
filtered := make([]database.ExternalRelease, 0, len(cachedReleases))
for _, r := range cachedReleases {
if opts.IgnoreSingles && r.Type == "Single" {
if opts.IgnoreSingles && (r.Type == "Single" || hasSliceType(r.SecondaryTypes, "Single")) {
continue
}
if opts.IgnoreCompilations && r.Type == "Compilation" {
if opts.IgnoreCompilations && (r.Type == "Compilation" || hasSliceType(r.SecondaryTypes, "Compilation")) {
continue
}
filtered = append(filtered, r)
@@ -152,6 +152,18 @@ func SyncArtistDiscography(
return releases, nil
}
// hasSliceType reports whether the slice contains the wanted value. It mirrors
// hasSecondaryType in api.go but operates on the persisted []string form read
// back from external_releases (cache-hit path).
func hasSliceType(types []string, wanted string) bool {
for _, t := range types {
if t == wanted {
return true
}
}
return false
}
// getArtistFilterOptions reads per-artist type filtering preferences.
// Defaults to no filtering if artist_settings row doesn't exist.
// artistID is the Navidrome artist ID (artist_settings.id), not the MusicBrainz ID.