Nano integration improvements
This commit is contained in:
@ -1,20 +1,55 @@
|
||||
package explore
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
const (
|
||||
currentlyAiringBonus = 5.0
|
||||
popularityThreshold = 5
|
||||
popularityPenalty = 8.0
|
||||
watchingPopularityWeight = 0.3
|
||||
plannedPopularityWeight = 0.2
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
// var cache arn.ListOfIDs
|
||||
// err := arn.DB.GetObject("Cache", "airing anime", &cache)
|
||||
animeList := arn.GetAiringAnime()
|
||||
|
||||
// airing, err := arn.GetAiringAnimeCached()
|
||||
sort.Slice(animeList, func(i, j int) bool {
|
||||
a := animeList[i]
|
||||
b := animeList[j]
|
||||
scoreA := a.Rating.Overall
|
||||
scoreB := b.Rating.Overall
|
||||
|
||||
// if err != nil {
|
||||
// return ctx.Error(500, "Couldn't fetch airing anime", err)
|
||||
// }
|
||||
if a.Status == "current" {
|
||||
scoreA += currentlyAiringBonus
|
||||
}
|
||||
|
||||
// return ctx.HTML(components.Airing(airing))
|
||||
return ctx.HTML("Not implemented")
|
||||
if b.Status == "current" {
|
||||
scoreB += currentlyAiringBonus
|
||||
}
|
||||
|
||||
if a.Popularity.Total() < popularityThreshold {
|
||||
scoreA -= popularityPenalty
|
||||
}
|
||||
|
||||
if b.Popularity.Total() < popularityThreshold {
|
||||
scoreB -= popularityPenalty
|
||||
}
|
||||
|
||||
scoreA += float64(a.Popularity.Watching) * watchingPopularityWeight
|
||||
scoreB += float64(b.Popularity.Watching) * watchingPopularityWeight
|
||||
|
||||
scoreA += float64(a.Popularity.Planned) * plannedPopularityWeight
|
||||
scoreB += float64(b.Popularity.Planned) * plannedPopularityWeight
|
||||
|
||||
return scoreA > scoreB
|
||||
})
|
||||
|
||||
return ctx.HTML(components.Explore(animeList))
|
||||
}
|
||||
|
Reference in New Issue
Block a user