New statistics
This commit is contained in:
parent
1fb5b4210e
commit
fc2130b2df
1
main.go
1
main.go
@ -93,6 +93,7 @@ func configure(app *aero.Application) *aero.Application {
|
||||
app.Ajax("/import/anilist/animelist/finish", listimportanilist.Finish)
|
||||
app.Ajax("/admin", admin.Get)
|
||||
app.Ajax("/statistics", statistics.Get)
|
||||
app.Ajax("/statistics/anime", statistics.Anime)
|
||||
app.Ajax("/search", search.Get)
|
||||
app.Ajax("/search/:term", search.Get)
|
||||
app.Ajax("/users", users.Get)
|
||||
|
48
pages/statistics/anime.go
Normal file
48
pages/statistics/anime.go
Normal file
@ -0,0 +1,48 @@
|
||||
package statistics
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Anime ...
|
||||
func Anime(ctx *aero.Context) string {
|
||||
allAnime, err := arn.AllAnime()
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Couldn't fetch anime", err)
|
||||
}
|
||||
|
||||
shoboi := stats{}
|
||||
anilist := stats{}
|
||||
status := stats{}
|
||||
types := stats{}
|
||||
|
||||
for _, anime := range allAnime {
|
||||
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"]++
|
||||
}
|
||||
|
||||
status[anime.Status]++
|
||||
types[anime.Type]++
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Statistics(
|
||||
utils.NewPieChart("Type", types),
|
||||
utils.NewPieChart("Status", status),
|
||||
utils.NewPieChart("Anilist", anilist),
|
||||
utils.NewPieChart("Shoboi", shoboi),
|
||||
))
|
||||
}
|
@ -18,7 +18,7 @@ func Get(ctx *aero.Context) string {
|
||||
analytics, err := arn.AllAnalytics()
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Couldn't retrieve analytics", err)
|
||||
return ctx.Error(http.StatusInternalServerError, "Couldn't fetch analytics", err)
|
||||
}
|
||||
|
||||
screenSize := stats{}
|
||||
@ -63,9 +63,9 @@ func Get(ctx *aero.Context) string {
|
||||
utils.NewPieChart("OS", os),
|
||||
// utils.NewPieChart("Platform", platform),
|
||||
utils.NewPieChart("Screen size", screenSize),
|
||||
utils.NewPieChart("Pixel ratio", pixelRatio),
|
||||
utils.NewPieChart("Browser", browser),
|
||||
utils.NewPieChart("Country", country),
|
||||
utils.NewPieChart("Gender", gender),
|
||||
utils.NewPieChart("Pixel ratio", pixelRatio),
|
||||
))
|
||||
}
|
||||
|
@ -1,12 +1,24 @@
|
||||
component Statistics(pieCharts ...*utils.PieChart)
|
||||
h1 Statistics
|
||||
|
||||
StatisticsHeader
|
||||
|
||||
.widgets.statistics
|
||||
each pie in pieCharts
|
||||
.widget
|
||||
h3.widget-title= pie.Title
|
||||
PieChart(pie.Slices)
|
||||
|
||||
component StatisticsHeader
|
||||
.buttons.tabs
|
||||
a.button.tab.action(href="/statistics", data-action="diff", data-trigger="click")
|
||||
Icon("user")
|
||||
span User
|
||||
|
||||
a.button.tab.action(href="/statistics/anime", data-action="diff", data-trigger="click")
|
||||
Icon("tv")
|
||||
span Anime
|
||||
|
||||
component PieChart(slices []*utils.PieChartSlice)
|
||||
svg.pie-chart(viewBox="-1.1 -1.1 2.2 2.2")
|
||||
each slice in slices
|
||||
|
Loading…
Reference in New Issue
Block a user