commit 32bd955ffce9c5ca514fb1cc9a997999d31fed58
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Tue Sep 13 10:33:05 2011 +0200
Graph GetTor packages by language, not by bundle.
With the recent renaming of GetTor package names it has become more
difficult to decide which packages are a TBB and which are something else.
tor-browser-bundle_en is now one out of linux-i386_en, linux-x86_64_en,
macosx-i386_en, or windows_en. And in the future there may be a TIMBB and
who knows what other packages.
Time to give up the guessing game. The language code is something we can
identify for certain. Let's graph that.
---
rserve/graphs.R | 24 ++++++++++++----
.../ernie/web/GraphParameterChecker.java | 28 ++++++++++----------
web/WEB-INF/packages.jsp | 11 ++++---
3 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/rserve/graphs.R b/rserve/graphs.R
index 959fd64..3c6d72a 100644
--- a/rserve/graphs.R
+++ b/rserve/graphs.R
@@ -254,6 +254,18 @@ countryname <- function(country) {
res
}
+languagelist <- list(
+ "en" = "English",
+ "fa" = "Farsi",
+ "zh_CN" = "Simplified Chinese")
+
+languagename <- function(language) {
+ res <- languagelist[[language]]
+ if (is.null(res))
+ res <- "Gibberish"
+ res
+}
+
date_breaks <- function(days) {
length <- cut(days, c(0, 7, 12, 56, 180, 600, 5000, Inf), labels=FALSE)
major <- c("days", "2 days", "weeks", "months", "3 months", "years",
@@ -704,11 +716,11 @@ plot_bridge_users <- function(start, end, country, path, dpi) {
ggsave(filename = path, width = 8, height = 5, dpi = as.numeric(dpi))
}
-plot_gettor <- function(start, end, bundle, path, dpi) {
+plot_gettor <- function(start, end, language, path, dpi) {
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, user = dbuser, password = dbpassword, dbname = db)
- condition <- ifelse(bundle == "all", "<> 'none'",
- paste("LIKE 'tor-%browser-bundle_", tolower(bundle), "'", sep = ""))
+ condition <- ifelse(language == "all", "<> 'none'",
+ paste("LIKE '%_", tolower(language), "'", sep = ""))
q <- paste("SELECT date, SUM(downloads) AS downloads ",
"FROM gettor_stats WHERE bundle ", condition, " AND date >= '",
start, "' AND date <= '", end,
@@ -725,10 +737,10 @@ plot_gettor <- function(start, end, bundle, path, dpi) {
downloads <- rbind(downloads,
data.frame(date = as.Date(missing, origin = "1970-01-01"),
downloads = NA))
- title <- ifelse(bundle == "all",
+ title <- ifelse(language == "all",
"Total packages requested from GetTor per day\n",
- paste("Tor Browser Bundles (", bundle,
- ") requested from GetTor per day\n", sep = ""))
+ paste(languagename(language), " (", language,
+ ") packages requested from GetTor per day\n", sep = ""))
date_breaks <- date_breaks(
as.numeric(max(as.Date(downloads$date, "%Y-%m-%d")) -
min(as.Date(downloads$date, "%Y-%m-%d"))))
diff --git a/src/org/torproject/ernie/web/GraphParameterChecker.java b/src/org/torproject/ernie/web/GraphParameterChecker.java
index 7349bf9..8189f19 100644
--- a/src/org/torproject/ernie/web/GraphParameterChecker.java
+++ b/src/org/torproject/ernie/web/GraphParameterChecker.java
@@ -53,7 +53,7 @@ public class GraphParameterChecker {
"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");
+ this.availableGraphs.put("gettor", "start,end,language,filename,dpi");
this.availableGraphs.put("torperf",
"start,end,source,filesize,filename,dpi");
this.availableGraphs.put("torperf-failures",
@@ -71,7 +71,7 @@ public class GraphParameterChecker {
}
this.knownParameterValues.put("country", sb.toString());
this.knownParameterValues.put("events", "on,off");
- this.knownParameterValues.put("bundle", "all,en,zh_CN,fa");
+ this.knownParameterValues.put("language", "all,en,zh_CN,fa");
this.knownParameterValues.put("source", "all,siv,moria,torperf");
this.knownParameterValues.put("filesize", "50kb,1mb,5mb");
this.knownParameterValues.put("dpi", "72,150,300");
@@ -218,24 +218,24 @@ public class GraphParameterChecker {
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
+ /* Parse language if supported by the graph type. Only a single
+ * language can be passed. If no language is passed, use "all" as
* default. */
- if (supportedGraphParameters.contains("bundle")) {
- String[] bundleParameter = (String[]) requestParameters.get(
- "bundle");
+ if (supportedGraphParameters.contains("language")) {
+ String[] languageParameter = (String[]) requestParameters.get(
+ "language");
List<String> knownBundles = Arrays.asList(
- this.knownParameterValues.get("bundle").split(","));
- if (bundleParameter != null) {
- if (bundleParameter.length != 1 ||
- bundleParameter[0].length() == 0 ||
- !knownBundles.contains(bundleParameter[0])) {
+ this.knownParameterValues.get("language").split(","));
+ if (languageParameter != null) {
+ if (languageParameter.length != 1 ||
+ languageParameter[0].length() == 0 ||
+ !knownBundles.contains(languageParameter[0])) {
return null;
}
} else {
- bundleParameter = new String[] { "all" };
+ languageParameter = new String[] { "all" };
}
- recognizedGraphParameters.put("bundle", bundleParameter);
+ recognizedGraphParameters.put("language", languageParameter);
}
/* Parse torperf data source if supported by the graph type. Only a
diff --git a/web/WEB-INF/packages.jsp b/web/WEB-INF/packages.jsp
index 9a19aca..9bfee70 100644
--- a/web/WEB-INF/packages.jsp
+++ b/web/WEB-INF/packages.jsp
@@ -33,11 +33,12 @@ graph shows the number of packages requested from GetTor per day.</p>
<input type="text" name="end" size="10"
value="<c:choose><c:when test="${fn:length(gettor_end) == 0}">${default_end_date}</c:when><c:otherwise>${gettor_end[0]}</c:otherwise></c:choose>">
</p><p>
- Packages:
- <input type="radio" name="bundle" value="all" <c:if test="${fn:length(gettor_bundle) == 0 or gettor_bundle[0] eq 'all'}"> checked</c:if>> Total packages
- <input type="radio" name="bundle" value="en" <c:if test="${gettor_bundle[0] eq 'en'}"> checked</c:if>> TBB (en)
- <input type="radio" name="bundle" value="zh_CN" <c:if test="${gettor_bundle[0] eq 'zh_CN'}"> checked</c:if>> TBB (zh_CN)
- <input type="radio" name="bundle" value="fa" <c:if test="${gettor_bundle[0] eq 'fa'}"> checked</c:if>> TBB (fa)
+ Language: <select name="language">
+ <option value="all"<c:if test="${fn:length(gettor_language) == 0 or gettor_language[0] eq 'all'}"> selected</c:if>>All languages</option>
+ <option value="en"<c:if test="${gettor_language[0] eq 'en'}"> selected</c:if>>English (en)</option>
+ <option value="zh_CN"<c:if test="${gettor_language[0] eq 'zh_CN'}"> selected</c:if>>Simplified Chinese (zh_CN)</option>
+ <option value="fa"<c:if test="${gettor_language[0] eq 'fa'}"> selected</c:if>>Farsi (fa)</option>
+ </select>
</p><p>
Resolution: <select name="dpi">
<option value="72"<c:if test="${gettor_dpi[0] eq '72'}"> selected</c:if>>Screen - 576x360</option>