New statistics

This commit is contained in:
Eduard Urbach 2017-10-16 01:07:08 +02:00
parent 68901ac25e
commit 7336fa2035
3 changed files with 19 additions and 19 deletions

View File

@ -43,6 +43,8 @@ func getUserStats() []*arn.PieChart {
os := stats{} os := stats{}
notifications := stats{} notifications := stats{}
avatar := stats{} avatar := stats{}
ip := stats{}
pro := stats{}
for _, info := range analytics { for _, info := range analytics {
user, err := arn.GetUser(info.UserID) user, err := arn.GetUser(info.UserID)
@ -52,7 +54,7 @@ func getUserStats() []*arn.PieChart {
continue continue
} }
pixelRatio[fmt.Sprintf("%.1f", info.Screen.PixelRatio)]++ pixelRatio[fmt.Sprintf("%.0f", info.Screen.PixelRatio)]++
size := arn.ToString(info.Screen.Width) + " x " + arn.ToString(info.Screen.Height) size := arn.ToString(info.Screen.Width) + " x " + arn.ToString(info.Screen.Height)
screenSize[size]++ screenSize[size]++
@ -94,6 +96,18 @@ func getUserStats() []*arn.PieChart {
} else { } else {
avatar[user.Avatar.Source]++ avatar[user.Avatar.Source]++
} }
if arn.IsIPv6(user.IP) {
ip["IPv6"]++
} else {
ip["IPv4"]++
}
if user.IsPro() {
pro["PRO account"]++
} else {
pro["Free account"]++
}
} }
println("Finished user statistics") println("Finished user statistics")
@ -107,6 +121,8 @@ func getUserStats() []*arn.PieChart {
arn.NewPieChart("Notifications", notifications), arn.NewPieChart("Notifications", notifications),
arn.NewPieChart("Gender", gender), arn.NewPieChart("Gender", gender),
arn.NewPieChart("Pixel ratio", pixelRatio), arn.NewPieChart("Pixel ratio", pixelRatio),
arn.NewPieChart("IP version", ip),
arn.NewPieChart("PRO accounts", pro),
} }
} }

View File

@ -1,12 +1,12 @@
package main package main
import ( import (
"fmt"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/fatih/color"
) )
func TestRoutes(t *testing.T) { func TestRoutes(t *testing.T) {
@ -24,7 +24,7 @@ func TestRoutes(t *testing.T) {
app.Handler().ServeHTTP(responseRecorder, request) app.Handler().ServeHTTP(responseRecorder, request)
if status := responseRecorder.Code; status != http.StatusOK { if status := responseRecorder.Code; status != http.StatusOK {
color.Red("%s | Wrong status code | %v instead of %v", example, status, http.StatusOK) panic(fmt.Errorf("%s | Wrong status code | %v instead of %v", example, status, http.StatusOK))
} }
} }
} }

View File

@ -100,14 +100,6 @@ var routeTests = map[string][]string{
"/api/animelist/4J6qpK1ve", "/api/animelist/4J6qpK1ve",
}, },
"/api/animelist/:id/get/:item": []string{
"/api/animelist/4J6qpK1ve/get/7929",
},
"/api/animelist/:id/get/:item/:property": []string{
"/api/animelist/4J6qpK1ve/get/7929/Episodes",
},
"/api/settings/:id": []string{ "/api/settings/:id": []string{
"/api/settings/4J6qpK1ve", "/api/settings/4J6qpK1ve",
}, },
@ -144,14 +136,6 @@ var routeTests = map[string][]string{
"/api/soundtrack/h0ac8sKkg", "/api/soundtrack/h0ac8sKkg",
}, },
"/api/soundcloudtosoundtrack/:id": []string{
"/api/soundcloudtosoundtrack/145918628",
},
"/api/youtubetosoundtrack/:id": []string{
"/api/youtubetosoundtrack/hU2wqJuOIp4",
},
"/api/userfollows/:id": []string{ "/api/userfollows/:id": []string{
"/api/userfollows/4J6qpK1ve", "/api/userfollows/4J6qpK1ve",
}, },