44 lines
835 B
Go
Raw Normal View History

2017-10-06 20:07:12 +00:00
package editor
2017-10-02 13:33:39 +00:00
import (
"net/http"
"sort"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
2017-10-06 20:07:12 +00:00
const maxShoboiEntries = 70
2017-10-02 13:33:39 +00:00
// Shoboi ...
func Shoboi(ctx *aero.Context) string {
missing, err := arn.FilterAnime(func(anime *arn.Anime) bool {
return anime.GetMapping("shoboi/anime") == ""
})
if err != nil {
ctx.Error(http.StatusInternalServerError, "Couldn't filter anime", err)
}
sort.Slice(missing, func(i, j int) bool {
2017-10-06 20:07:12 +00:00
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
2017-10-02 13:33:39 +00:00
})
2017-10-06 20:07:12 +00:00
if len(missing) > maxShoboiEntries {
missing = missing[:maxShoboiEntries]
}
2017-10-02 13:33:39 +00:00
return ctx.HTML(components.ShoboiMissingMapping(missing))
}