New statistics

This commit is contained in:
Eduard Urbach 2017-07-07 11:05:01 +02:00
parent fc2130b2df
commit b75ec453f5

View File

@ -21,8 +21,31 @@ func Anime(ctx *aero.Context) string {
anilist := stats{} anilist := stats{}
status := stats{} status := stats{}
types := stats{} types := stats{}
shoboiEdits := stats{}
anilistEdits := stats{}
rating := stats{}
for _, anime := range allAnime { for _, anime := range allAnime {
for _, external := range anime.Mappings {
if external.Service == "shoboi/anime" {
if external.CreatedBy == "" {
shoboiEdits["Bot"]++
} else {
user, _ := arn.GetUser(external.CreatedBy)
shoboiEdits[user.Nick]++
}
}
if external.Service == "anilist/anime" {
if external.CreatedBy == "" {
anilistEdits["Bot"]++
} else {
user, _ := arn.GetUser(external.CreatedBy)
anilistEdits[user.Nick]++
}
}
}
if anime.GetMapping("shoboi/anime") != "" { if anime.GetMapping("shoboi/anime") != "" {
shoboi["Connected with Shoboi"]++ shoboi["Connected with Shoboi"]++
} else { } else {
@ -35,6 +58,8 @@ func Anime(ctx *aero.Context) string {
anilist["Not connected with Anilist"]++ anilist["Not connected with Anilist"]++
} }
rating[arn.ToString(int(anime.Rating.Overall+0.5))]++
status[anime.Status]++ status[anime.Status]++
types[anime.Type]++ types[anime.Type]++
} }
@ -42,7 +67,10 @@ func Anime(ctx *aero.Context) string {
return ctx.HTML(components.Statistics( return ctx.HTML(components.Statistics(
utils.NewPieChart("Type", types), utils.NewPieChart("Type", types),
utils.NewPieChart("Status", status), utils.NewPieChart("Status", status),
utils.NewPieChart("Rating", rating),
utils.NewPieChart("Anilist", anilist), utils.NewPieChart("Anilist", anilist),
utils.NewPieChart("Anilist Editors", anilistEdits),
utils.NewPieChart("Shoboi", shoboi), utils.NewPieChart("Shoboi", shoboi),
utils.NewPieChart("Shoboi Editors", shoboiEdits),
)) ))
} }