From 0c61456e4efbfbd27589e0ca6cbad75b96557894 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 2 Dec 2017 19:55:16 +0100 Subject: [PATCH] Added genre statistics --- pages/profile/stats.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pages/profile/stats.go b/pages/profile/stats.go index aac19d76..d13c1923 100644 --- a/pages/profile/stats.go +++ b/pages/profile/stats.go @@ -23,6 +23,7 @@ func GetStatsByUser(ctx *aero.Context) string { types := stats{} years := stats{} studios := stats{} + genres := stats{} if err != nil { return ctx.Error(http.StatusNotFound, "User not found", err) @@ -51,6 +52,10 @@ func GetStatsByUser(ctx *aero.Context) string { studios[studio.Name.English]++ } + for _, genre := range item.Anime().Genres { + genres[genre]++ + } + if item.Anime().StartDate != "" { year := item.Anime().StartDate[:4] @@ -63,11 +68,12 @@ func GetStatsByUser(ctx *aero.Context) string { } userStats.PieCharts = []*arn.PieChart{ - arn.NewPieChart("Ratings", ratings), - arn.NewPieChart("Status", status), - arn.NewPieChart("Types", types), + arn.NewPieChart("Genres", genres), arn.NewPieChart("Studios", studios), 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()))