2018-03-07 03:03:15 +00:00
|
|
|
package editor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sort"
|
|
|
|
|
|
|
|
"github.com/aerogo/aero"
|
|
|
|
"github.com/animenotifier/arn"
|
|
|
|
"github.com/animenotifier/notify.moe/components"
|
|
|
|
)
|
|
|
|
|
|
|
|
const maxGenreEntries = 70
|
|
|
|
|
|
|
|
// Genres ...
|
|
|
|
func Genres(ctx *aero.Context) string {
|
2018-03-07 21:06:02 +00:00
|
|
|
year, _ := ctx.GetInt("year")
|
|
|
|
animeType := ctx.Get("type")
|
|
|
|
|
2018-03-07 03:03:15 +00:00
|
|
|
missing := arn.FilterAnime(func(anime *arn.Anime) bool {
|
2018-03-07 21:06:02 +00:00
|
|
|
if year != 0 && year != anime.StartDateTime().Year() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if animeType != "" && anime.Type != animeType {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-03-07 03:03:15 +00:00
|
|
|
return len(anime.Genres) == 0
|
|
|
|
})
|
|
|
|
|
|
|
|
sort.Slice(missing, func(i, j int) bool {
|
|
|
|
a := missing[i]
|
|
|
|
b := missing[j]
|
|
|
|
|
|
|
|
aPop := a.Popularity.Total()
|
|
|
|
bPop := b.Popularity.Total()
|
|
|
|
|
|
|
|
if aPop == bPop {
|
|
|
|
return a.Title.Canonical < b.Title.Canonical
|
|
|
|
}
|
|
|
|
|
|
|
|
return aPop > bPop
|
|
|
|
})
|
|
|
|
|
2018-03-07 20:25:24 +00:00
|
|
|
count := len(missing)
|
|
|
|
|
|
|
|
if count > maxGenreEntries {
|
2018-03-07 03:03:15 +00:00
|
|
|
missing = missing[:maxGenreEntries]
|
|
|
|
}
|
|
|
|
|
2018-03-07 20:25:24 +00:00
|
|
|
return ctx.HTML(components.AnimeEditorListFull(
|
|
|
|
"Anime without genres",
|
|
|
|
missing,
|
|
|
|
count,
|
2018-03-09 11:38:46 +00:00
|
|
|
"/editor/anime/missing/genres",
|
2018-03-07 20:25:24 +00:00
|
|
|
nil,
|
|
|
|
))
|
2018-03-07 03:03:15 +00:00
|
|
|
}
|