44 lines
780 B
Go
Raw Normal View History

2018-03-22 19:15:21 +00:00
package filteranime
import (
"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")
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
}
return len(anime.Genres) == 0
})
2018-03-22 19:15:21 +00:00
arn.SortAnimeByQuality(missing)
count := len(missing)
if count > maxGenreEntries {
missing = missing[:maxGenreEntries]
}
return ctx.HTML(components.AnimeEditorListFull(
"Anime without genres",
missing,
count,
2018-03-20 15:53:23 +00:00
ctx.URI(),
nil,
))
}