Added genre statistics
This commit is contained in:
parent
21f28f34dc
commit
0c61456e4e
@ -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()))
|
||||||
|
Loading…
Reference in New Issue
Block a user