2017-07-07 08:57:48 +00:00
|
|
|
package statistics
|
|
|
|
|
|
|
|
import (
|
2018-04-19 20:01:28 +00:00
|
|
|
"fmt"
|
|
|
|
|
2017-07-07 08:57:48 +00:00
|
|
|
"github.com/aerogo/aero"
|
2019-06-03 09:32:43 +00:00
|
|
|
"github.com/animenotifier/notify.moe/arn"
|
2017-10-28 01:53:12 +00:00
|
|
|
"github.com/animenotifier/notify.moe/components"
|
2017-07-07 08:57:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Anime ...
|
2019-06-01 04:55:49 +00:00
|
|
|
func Anime(ctx aero.Context) error {
|
2017-10-28 01:53:12 +00:00
|
|
|
pieCharts := getAnimeStats()
|
|
|
|
return ctx.HTML(components.Statistics(pieCharts))
|
|
|
|
}
|
|
|
|
|
|
|
|
func getAnimeStats() []*arn.PieChart {
|
|
|
|
shoboi := stats{}
|
|
|
|
anilist := stats{}
|
|
|
|
mal := stats{}
|
|
|
|
anidb := stats{}
|
|
|
|
status := stats{}
|
|
|
|
types := stats{}
|
|
|
|
rating := stats{}
|
|
|
|
twist := stats{}
|
|
|
|
|
|
|
|
for anime := range arn.StreamAnime() {
|
|
|
|
if anime.GetMapping("shoboi/anime") != "" {
|
|
|
|
shoboi["Connected with Shoboi"]++
|
|
|
|
} else {
|
|
|
|
shoboi["Not connected with Shoboi"]++
|
|
|
|
}
|
|
|
|
|
|
|
|
if anime.GetMapping("anilist/anime") != "" {
|
|
|
|
anilist["Connected with AniList"]++
|
|
|
|
} else {
|
|
|
|
anilist["Not connected with AniList"]++
|
|
|
|
}
|
|
|
|
|
|
|
|
if anime.GetMapping("myanimelist/anime") != "" {
|
|
|
|
mal["Connected with MyAnimeList"]++
|
|
|
|
} else {
|
|
|
|
mal["Not connected with MyAnimeList"]++
|
|
|
|
}
|
|
|
|
|
|
|
|
if anime.GetMapping("anidb/anime") != "" {
|
|
|
|
anidb["Connected with AniDB"]++
|
|
|
|
} else {
|
|
|
|
anidb["Not connected with AniDB"]++
|
|
|
|
}
|
|
|
|
|
2018-04-19 20:01:28 +00:00
|
|
|
rating[fmt.Sprint(int(anime.Rating.Overall+0.5))]++
|
2017-10-28 01:53:12 +00:00
|
|
|
|
|
|
|
found := false
|
|
|
|
for _, episode := range anime.Episodes().Items {
|
|
|
|
if episode.Links != nil && episode.Links["twist.moe"] != "" {
|
|
|
|
found = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if found {
|
|
|
|
twist["Connected with AnimeTwist"]++
|
|
|
|
} else {
|
|
|
|
twist["Not connected with AnimeTwist"]++
|
|
|
|
}
|
|
|
|
|
|
|
|
status[anime.Status]++
|
|
|
|
types[anime.Type]++
|
|
|
|
}
|
|
|
|
|
|
|
|
return []*arn.PieChart{
|
|
|
|
arn.NewPieChart("Type", types),
|
|
|
|
arn.NewPieChart("Status", status),
|
|
|
|
arn.NewPieChart("Rating", rating),
|
|
|
|
arn.NewPieChart("MyAnimeList", mal),
|
|
|
|
arn.NewPieChart("AniList", anilist),
|
|
|
|
arn.NewPieChart("AniDB", anidb),
|
|
|
|
arn.NewPieChart("Shoboi", shoboi),
|
|
|
|
arn.NewPieChart("AnimeTwist", twist),
|
|
|
|
}
|
2017-07-07 08:57:48 +00:00
|
|
|
}
|