[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [metrics-web/master] Add webstats-tb-locale graph.



commit 8258b18aff005fcdb6b44d5dee81ac55fa0b7fa2
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Tue Jan 31 16:26:22 2017 +0100

    Add webstats-tb-locale graph.
---
 website/etc/categories.json |  1 +
 website/etc/metrics.json    | 14 ++++++++++++++
 website/etc/web.xml         |  4 ++++
 website/rserve/graphs.R     | 33 +++++++++++++++++++++++++++++++++
 4 files changed, 52 insertions(+)

diff --git a/website/etc/categories.json b/website/etc/categories.json
index 64b5c1a..134ef44 100644
--- a/website/etc/categories.json
+++ b/website/etc/categories.json
@@ -81,6 +81,7 @@
     "description": "The following application statistics are based on the analysis of requests to <code>torproject.org</code> web servers.",
     "metrics": [
       "webstats-tb",
+      "webstats-tb-locale",
       "webstats-tm"
     ]
   }
diff --git a/website/etc/metrics.json b/website/etc/metrics.json
index 2601318..41e2c6f 100644
--- a/website/etc/metrics.json
+++ b/website/etc/metrics.json
@@ -418,6 +418,20 @@
     ]
   },
   {
+    "id": "webstats-tb-locale",
+    "title": "Tor Browser downloads by locale",
+    "type": "Graph",
+    "description": "<p>This graph shows absolute numbers of requests to Tor's web servers by request type.  It is based on data from <a href=\"https://webstats.torproject.org/\"; target=\"_blank\"><code>webstats.torproject.org</code></a> which collects logs from <code>torproject.org</code> web servers and provides them as a stripped-down version of Apache's \"combined\" log format without IP addresses, log times, HTTP parameters, referers, and user agent strings.  All shown requests are requests made by the user to download a Tor Browser executable from the Tor website, broken down by requested locale.</p>",
+    "function": "plot_webstats_tb_locale",
+    "parameters": [
+      "start",
+      "end"
+    ],
+    "data": [
+      "webstats"
+    ]
+  },
+  {
     "id": "webstats-tm",
     "title": "Tor Messenger downloads and updates",
     "type": "Graph",
diff --git a/website/etc/web.xml b/website/etc/web.xml
index adfc370..9e42aa5 100644
--- a/website/etc/web.xml
+++ b/website/etc/web.xml
@@ -47,6 +47,7 @@
     <url-pattern>/hidserv-rend-relayed-cells.html</url-pattern>
     <url-pattern>/hidserv-frac-reporting.html</url-pattern>
     <url-pattern>/webstats-tb.html</url-pattern>
+    <url-pattern>/webstats-tb-locale.html</url-pattern>
     <url-pattern>/webstats-tm.html</url-pattern>
   </servlet-mapping>
 
@@ -182,6 +183,9 @@
     <url-pattern>/webstats-tb.png</url-pattern>
     <url-pattern>/webstats-tb.pdf</url-pattern>
     <url-pattern>/webstats-tb.svg</url-pattern>
+    <url-pattern>/webstats-tb-locale.png</url-pattern>
+    <url-pattern>/webstats-tb-locale.pdf</url-pattern>
+    <url-pattern>/webstats-tb-locale.svg</url-pattern>
     <url-pattern>/webstats-tm.png</url-pattern>
     <url-pattern>/webstats-tm.pdf</url-pattern>
     <url-pattern>/webstats-tm.svg</url-pattern>
diff --git a/website/rserve/graphs.R b/website/rserve/graphs.R
index e854aff..1b232f4 100644
--- a/website/rserve/graphs.R
+++ b/website/rserve/graphs.R
@@ -1126,6 +1126,39 @@ plot_webstats_tb <- function(start, end, path) {
   ggsave(filename = path, width = 8, height = 5, dpi = 72)
 }
 
+plot_webstats_tb_locale <- function(start, end, path) {
+  end <- min(end, as.character(Sys.Date() - 2))
+  d <- read.csv(paste("/srv/metrics.torproject.org/metrics/shared/stats/",
+                "webstats.csv", sep = ""), stringsAsFactors = FALSE)
+  d <- d[d$log_date >= start & d$log_date <= end & d$request_type == 'tbid', ]
+  e <- d
+  e <- aggregate(list(count = e$count), by = list(locale = e$locale), FUN = sum)
+  e <- e[order(e$count, decreasing = TRUE), ]
+  e <- e[1:5, ]
+  d <- aggregate(list(count = d$count), by = list(log_date = as.Date(d$log_date),
+    locale = ifelse(d$locale %in% e$locale, d$locale, '(other)')), FUN = sum)
+  date_breaks <- date_breaks(as.numeric(max(d$log_date) - min(d$log_date)))
+  formatter <- function(x, ...) {
+    format(x, ..., scientific = FALSE, big.mark = ' ') }
+  ggplot(d, aes(x = log_date, y = count, colour = locale)) +
+    geom_point() +
+    geom_line() +
+    expand_limits(y = 0) +
+    scale_x_date(name = paste("\nThe Tor Project - ",
+        "https://metrics.torproject.org/";, sep = ""),
+        labels = date_format(date_breaks$format),
+        breaks = date_breaks$major,
+        minor_breaks = date_breaks$minor) +
+    scale_y_continuous(name = 'Requests per day\n', labels = formatter) +
+    scale_colour_hue(name = "Locale",
+        breaks = c(e$locale, "(other)"),
+        labels = c(e$locale, "Other")) +
+    theme(strip.text.y = element_text(angle = 0, hjust = 0, size = rel(1.5)),
+          strip.background = element_rect(fill = NA)) +
+    ggtitle("Tor Browser downloads by locale\n")
+  ggsave(filename = path, width = 8, height = 5, dpi = 72)
+}
+
 plot_webstats_tm <- function(start, end, path) {
   end <- min(end, as.character(Sys.Date() - 2))
   load("/srv/metrics.torproject.org/metrics/shared/RData/webstats-tm.RData")

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits