commit e2962c7876c50da134b286736cff50e57bb5759e Author: Karsten Loesing karsten.loesing@gmx.net Date: Mon Sep 16 16:53:43 2013 +0200
Add monthly aggregates to new user estimates. --- rserve/csv.R | 28 ++++++++++++++++++++ .../ernie/web/graphs/RObjectGenerator.java | 2 ++ web/WEB-INF/users.jsp | 5 ++++ 3 files changed, 35 insertions(+)
diff --git a/rserve/csv.R b/rserve/csv.R index efb4486..531e73f 100644 --- a/rserve/csv.R +++ b/rserve/csv.R @@ -300,3 +300,31 @@ export_userstats <- function(path) { quote = FALSE, row.names = FALSE) }
+help_export_monthly_userstats <- function(path, aggr_fun) { + u <- read.csv(paste("/srv/metrics.torproject.org/task-8462-graphs/", + "task-8462/userstats.csv", sep = ""), + stringsAsFactors = FALSE) + u <- u[u$country != '' & u$transport == '' & u$version == '', + c("date", "country", "users")] + u <- aggregate(list(users = u$users), + by = list(date = u$date, country = u$country), sum) + u <- aggregate(list(users = u$users), + by = list(country = u$country, + month = substr(u$date, 1, 7)), aggr_fun) + u <- rbind(u, data.frame(country = "zy", + aggregate(list(users = u$users), + by = list(month = u$month), sum))) + u <- cast(u, country ~ month, value = "users") + u[u$country == "zy", "country"] <- "all" + u[, 2:length(u)] <- floor(u[, 2:length(u)]) + write.csv(u, path, quote = FALSE, row.names = FALSE) +} + +export_monthly_userstats_peak <- function(path) { + help_export_monthly_userstats(path, max) +} + +export_monthly_userstats_average <- function(path) { + help_export_monthly_userstats(path, mean) +} + diff --git a/src/org/torproject/ernie/web/graphs/RObjectGenerator.java b/src/org/torproject/ernie/web/graphs/RObjectGenerator.java index a927578..84d61c6 100644 --- a/src/org/torproject/ernie/web/graphs/RObjectGenerator.java +++ b/src/org/torproject/ernie/web/graphs/RObjectGenerator.java @@ -67,6 +67,8 @@ public class RObjectGenerator implements ServletContextListener { this.availableCsvFiles.add("dirbytes"); this.availableCsvFiles.add("monthly-users-average"); this.availableCsvFiles.add("monthly-users-peak"); + this.availableCsvFiles.add("monthly-userstats-average"); + this.availableCsvFiles.add("monthly-userstats-peak"); this.availableCsvFiles.add("networksize"); this.availableCsvFiles.add("platforms"); this.availableCsvFiles.add("relaycountries"); diff --git a/web/WEB-INF/users.jsp b/web/WEB-INF/users.jsp index 10b630a..2a7bede 100644 --- a/web/WEB-INF/users.jsp +++ b/web/WEB-INF/users.jsp @@ -448,6 +448,11 @@ IPv6 numbers will become more accurate over time.</font>
<p><a href="csv/userstats.csv">CSV</a> file containing new user estimates (BETA).</p> +<p><a href="csv/monthly-userstats-peak.csv">CSV</a> file containing peak +daily Tor users (direct and bridge) per month by country (BETA).</p> +<p><a href="csv/monthly-userstats-average.csv">CSV</a> file containing +average daily Tor users (direct and bridge) per month by country +(BETA).</p> <br>
</div>
tor-commits@lists.torproject.org