[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-web/master] Show possible censorship events in user graphs.
commit ca34678f08780173a2e6736acf48db80e5903f3a
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Mon Jul 11 13:24:33 2011 +0200
Show possible censorship events in user graphs.
---
rserve/graphs.R | 23 ++++++++++++++++++-
.../ernie/web/GraphParameterChecker.java | 23 +++++++++++++++++++-
web/WEB-INF/users.jsp | 5 ++++
3 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/rserve/graphs.R b/rserve/graphs.R
index cff39a2..c6ba4fd 100644
--- a/rserve/graphs.R
+++ b/rserve/graphs.R
@@ -600,7 +600,7 @@ plot_relayflags <- function(start, end, flags, granularity, path, dpi) {
ggsave(filename = path, width = 8, height = 5, dpi = as.numeric(dpi))
}
-plot_direct_users <- function(start, end, country, path, dpi) {
+plot_direct_users <- function(start, end, country, events, path, dpi) {
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, user = dbuser, password = dbpassword, dbname = db)
q <- paste("SELECT date, r, bwp, brn, bwn, brp, bwr, brr ",
@@ -630,7 +630,25 @@ plot_direct_users <- function(start, end, country, path, dpi) {
date_breaks <- date_breaks(
as.numeric(max(as.Date(u$date, "%Y-%m-%d")) -
min(as.Date(u$date, "%Y-%m-%d"))))
- ggplot(u, aes(x = as.Date(date, "%Y-%m-%d"), y = users)) +
+ plot <- ggplot(u, aes(x = as.Date(date, "%Y-%m-%d"), y = users))
+ if (events == "on" & country != "all") {
+ r <- read.csv(
+ "/srv/metrics.torproject.org/web/direct-users-ranges.csv",
+ stringsAsFactors = FALSE)
+ r <- r[r$date >= start & r$date <= end & r$country == country,
+ c("date", "minusers", "maxusers")]
+ r <- cast(rbind(melt(u, id.vars = "date"), melt(r, id.vars = "date")))
+ upturns <- r[r$users > r$maxusers, 1:2]
+ downturns <- r[r$users < r$minusers, 1:2]
+ plot <- plot +
+ geom_ribbon(data = r, aes(ymin = minusers, ymax = maxusers),
+ fill = "gray") +
+ geom_point(data = upturns, aes(x = date, y = users), size = 5,
+ colour = "dodgerblue2") +
+ geom_point(data = downturns, aes(x = date, y = users), size = 5,
+ colour = "firebrick2")
+ }
+ plot <- plot +
geom_line(size = 1) +
scale_x_date(name = paste("\nThe Tor Project - ",
"https://metrics.torproject.org/", sep = ""),
@@ -639,6 +657,7 @@ plot_direct_users <- function(start, end, country, path, dpi) {
scale_y_continuous(name = "", limits = c(0, max(u$users,
na.rm = TRUE)), formatter = formatter) +
opts(title = title)
+ print(plot)
ggsave(filename = path, width = 8, height = 5, dpi = as.numeric(dpi))
}
diff --git a/src/org/torproject/ernie/web/GraphParameterChecker.java b/src/org/torproject/ernie/web/GraphParameterChecker.java
index 95e4cf0..7349bf9 100644
--- a/src/org/torproject/ernie/web/GraphParameterChecker.java
+++ b/src/org/torproject/ernie/web/GraphParameterChecker.java
@@ -50,7 +50,7 @@ public class GraphParameterChecker {
this.availableGraphs.put("bwhist-flags", "start,end,filename,dpi");
this.availableGraphs.put("dirbytes", "start,end,filename,dpi");
this.availableGraphs.put("direct-users",
- "start,end,country,filename,dpi");
+ "start,end,country,events,filename,dpi");
this.availableGraphs.put("bridge-users",
"start,end,country,filename,dpi");
this.availableGraphs.put("gettor", "start,end,bundle,filename,dpi");
@@ -70,6 +70,7 @@ public class GraphParameterChecker {
sb.append("," + country[0]);
}
this.knownParameterValues.put("country", sb.toString());
+ this.knownParameterValues.put("events", "on,off");
this.knownParameterValues.put("bundle", "all,en,zh_CN,fa");
this.knownParameterValues.put("source", "all,siv,moria,torperf");
this.knownParameterValues.put("filesize", "50kb,1mb,5mb");
@@ -197,6 +198,26 @@ public class GraphParameterChecker {
recognizedGraphParameters.put("country", countryParameters);
}
+ /* Parse whether the estimated min/max range shall be displayed if
+ * supported by the graph type. This parameter can either be "on" or
+ * "off," where "off" is the default. */
+ if (supportedGraphParameters.contains("events")) {
+ String[] eventsParameter = (String[]) requestParameters.get(
+ "events");
+ List<String> knownRanges = Arrays.asList(
+ this.knownParameterValues.get("events").split(","));
+ if (eventsParameter != null) {
+ if (eventsParameter.length != 1 ||
+ eventsParameter[0].length() == 0 ||
+ !knownRanges.contains(eventsParameter[0])) {
+ return null;
+ }
+ } else {
+ eventsParameter = new String[] { "off" };
+ }
+ recognizedGraphParameters.put("events", eventsParameter);
+ }
+
/* Parse GetTor bundle if supported by the graph type. Only a single
* bundle can be passed. If no bundle is passed, use "all" as
* default. */
diff --git a/web/WEB-INF/users.jsp b/web/WEB-INF/users.jsp
index 60be8ab..814c15c 100644
--- a/web/WEB-INF/users.jsp
+++ b/web/WEB-INF/users.jsp
@@ -43,6 +43,11 @@ based on the requests seen by a few dozen directory mirrors.</p>
</c:forEach>
</select>
</p><p>
+ Show possible censorship events if available (BETA)
+ <input type="checkbox" name="events" value="on"
+ <c:if test="${direct_users_events[0] eq 'on'}"> checked</c:if>
+ ></input>
+ </p><p>
Resolution: <select name="dpi">
<option value="72"<c:if test="${direct_users_dpi[0] eq '72'}"> selected</c:if>>Screen - 576x360</option>
<option value="150"<c:if test="${direct_users_dpi[0] eq '150'}"> selected</c:if>>Print low - 1200x750</option>
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits