fix: address code review findings
This commit is contained in:
@@ -80,13 +80,13 @@ type FilterOptions struct {
|
||||
func FilterReleaseGroups(groups []ReleaseGroup, opts FilterOptions) []ReleaseGroup {
|
||||
var filtered []ReleaseGroup
|
||||
for _, rg := range groups {
|
||||
if !IsTypeIncluded(rg.Type) && !hasSecondaryType(rg, "Single", "EP", "Compilation") {
|
||||
if !IsTypeIncluded(rg.Type) && !hasSliceType(rg.SecondaryTypes, "Single", "EP", "Compilation") {
|
||||
continue
|
||||
}
|
||||
if opts.IgnoreSingles && (rg.Type == "Single" || hasSecondaryType(rg, "Single")) {
|
||||
if opts.IgnoreSingles && (rg.Type == "Single" || hasSliceType(rg.SecondaryTypes, "Single")) {
|
||||
continue
|
||||
}
|
||||
if opts.IgnoreCompilations && (rg.Type == "Compilation" || hasSecondaryType(rg, "Compilation")) {
|
||||
if opts.IgnoreCompilations && (rg.Type == "Compilation" || hasSliceType(rg.SecondaryTypes, "Compilation")) {
|
||||
continue
|
||||
}
|
||||
filtered = append(filtered, rg)
|
||||
@@ -106,12 +106,6 @@ func hasSliceType(types []string, wanted ...string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// hasSecondaryType reports whether any of the release group's secondary types
|
||||
// matches one of the provided values.
|
||||
func hasSecondaryType(rg ReleaseGroup, wanted ...string) bool {
|
||||
return hasSliceType(rg.SecondaryTypes, wanted...)
|
||||
}
|
||||
|
||||
// IsTypeIncluded returns true if the given primary type is in the base
|
||||
// included set (Album/Single/EP).
|
||||
func IsTypeIncluded(releaseType string) bool {
|
||||
|
||||
Reference in New Issue
Block a user