From 92c6a7e4b48f29d743e2aed4da54b3548143a892 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 15 Jul 2017 19:31:34 +0200 Subject: [PATCH] New statistics --- jobs/statistics/statistics.go | 17 +++++++++++++++++ patches/add-episodes/add-episodes.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 patches/add-episodes/add-episodes.go diff --git a/jobs/statistics/statistics.go b/jobs/statistics/statistics.go index 74a4d81d..6ed1fdf1 100644 --- a/jobs/statistics/statistics.go +++ b/jobs/statistics/statistics.go @@ -20,6 +20,7 @@ func main() { Name: "Users", PieCharts: userStats, })) + arn.PanicOnError(arn.DB.Set("Cache", "anime statistics", &arn.StatisticsCategory{ Name: "Anime", PieCharts: animeStats, @@ -40,6 +41,8 @@ func getUserStats() []*arn.PieChart { country := stats{} gender := stats{} os := stats{} + notifications := stats{} + activity := stats{} for _, info := range analytics { pixelRatio[fmt.Sprintf("%.1f", info.Screen.PixelRatio)]++ @@ -68,6 +71,18 @@ func getUserStats() []*arn.PieChart { os[user.OS.Name]++ } + + if len(user.PushSubscriptions().Items) > 0 { + notifications["Enabled"]++ + } else { + notifications["Disabled"]++ + } + + if user.IsActive() { + activity["Active last week"]++ + } else { + activity["Inactive"]++ + } } println("Finished user statistics") @@ -77,6 +92,8 @@ func getUserStats() []*arn.PieChart { arn.NewPieChart("Screen size", screenSize), arn.NewPieChart("Browser", browser), arn.NewPieChart("Country", country), + arn.NewPieChart("Activity", activity), + arn.NewPieChart("Notifications", notifications), arn.NewPieChart("Gender", gender), arn.NewPieChart("Pixel ratio", pixelRatio), } diff --git a/patches/add-episodes/add-episodes.go b/patches/add-episodes/add-episodes.go new file mode 100644 index 00000000..111d0644 --- /dev/null +++ b/patches/add-episodes/add-episodes.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + + "github.com/animenotifier/arn" +) + +func main() { + count := 0 + + for anime := range arn.MustStreamAnime() { + episodes := anime.Episodes() + + if episodes == nil { + episodes = &arn.AnimeEpisodes{ + AnimeID: anime.ID, + Items: []*arn.AnimeEpisode{}, + } + + if episodes.Save() == nil { + count++ + } + } + } + + fmt.Println("Added empty anime episodes to", count, "anime.") +}