Add filter for duplicate mappings
This commit is contained in:
@ -40,6 +40,7 @@ component EditorTabs(url string, user *arn.User)
|
||||
Tab("MAL", "arrows-h", "/editor/anime/mapping/mal" + user.Settings().Editor.Filter.Suffix())
|
||||
Tab("Shoboi", "arrows-h", "/editor/anime/mapping/shoboi" + user.Settings().Editor.Filter.Suffix())
|
||||
Tab("AniList", "arrows-h", "/editor/anime/mapping/anilist" + user.Settings().Editor.Filter.Suffix())
|
||||
Tab("Duplicate", "exclamation-circle", "/editor/anime/mapping/duplicate" + user.Settings().Editor.Filter.Suffix())
|
||||
|
||||
if strings.Contains(url, "/editor/anime/image/")
|
||||
.tabs
|
||||
|
30
pages/editor/filteranime/duplicate-mapping.go
Normal file
30
pages/editor/filteranime/duplicate-mapping.go
Normal file
@ -0,0 +1,30 @@
|
||||
package filteranime
|
||||
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
)
|
||||
|
||||
// DuplicateMappings ...
|
||||
func DuplicateMappings(ctx *aero.Context) string {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime with duplicate mappings",
|
||||
func(anime *arn.Anime) bool {
|
||||
all := map[string]bool{}
|
||||
|
||||
for _, mapping := range anime.Mappings {
|
||||
_, exists := all[mapping.Service]
|
||||
|
||||
if exists {
|
||||
return true
|
||||
}
|
||||
|
||||
all[mapping.Service] = true
|
||||
}
|
||||
|
||||
return false
|
||||
},
|
||||
nil,
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user