Added genre statistics

This commit is contained in:
Eduard Urbach 2017-12-02 19:55:16 +01:00
parent 21f28f34dc
commit 0c61456e4e

View File

@ -23,6 +23,7 @@ func GetStatsByUser(ctx *aero.Context) string {
types := stats{} types := stats{}
years := stats{} years := stats{}
studios := stats{} studios := stats{}
genres := stats{}
if err != nil { if err != nil {
return ctx.Error(http.StatusNotFound, "User not found", err) return ctx.Error(http.StatusNotFound, "User not found", err)
@ -51,6 +52,10 @@ func GetStatsByUser(ctx *aero.Context) string {
studios[studio.Name.English]++ studios[studio.Name.English]++
} }
for _, genre := range item.Anime().Genres {
genres[genre]++
}
if item.Anime().StartDate != "" { if item.Anime().StartDate != "" {
year := item.Anime().StartDate[:4] year := item.Anime().StartDate[:4]
@ -63,11 +68,12 @@ func GetStatsByUser(ctx *aero.Context) string {
} }
userStats.PieCharts = []*arn.PieChart{ userStats.PieCharts = []*arn.PieChart{
arn.NewPieChart("Ratings", ratings), arn.NewPieChart("Genres", genres),
arn.NewPieChart("Status", status),
arn.NewPieChart("Types", types),
arn.NewPieChart("Studios", studios), arn.NewPieChart("Studios", studios),
arn.NewPieChart("Years", years), arn.NewPieChart("Years", years),
arn.NewPieChart("Ratings", ratings),
arn.NewPieChart("Types", types),
arn.NewPieChart("Status", status),
} }
return ctx.HTML(components.ProfileStats(&userStats, viewUser, utils.GetUser(ctx), ctx.URI())) return ctx.HTML(components.ProfileStats(&userStats, viewUser, utils.GetUser(ctx), ctx.URI()))