[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-web/master] Add an option to not cut off the last day(s) in a graph.
commit 9677fbdaa5c0892bd54364277654264b6dd51480
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Wed Sep 14 21:14:25 2011 +0200
Add an option to not cut off the last day(s) in a graph.
Note that we cut off the last day(s) for a reason. The data may be wrong.
Whatever you do there, it's your own risk. Don't blame the metrics guy!
---
rserve/graphs.R | 6 +++-
.../ernie/web/GraphParameterChecker.java | 23 +++++++++++++++++++-
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/rserve/graphs.R b/rserve/graphs.R
index 7f417a0..1b5fd43 100644
--- a/rserve/graphs.R
+++ b/rserve/graphs.R
@@ -617,12 +617,14 @@ 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, events, path, dpi) {
+plot_direct_users <- function(start, end, country, events, path, nocutoff,
+ dpi) {
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, user = dbuser, password = dbpassword, dbname = db)
q <- paste("SELECT date, r, bwp, brn, bwn, brp, bwr, brr ",
"FROM user_stats WHERE date >= '", start, "' AND date <= '", end,
- "' AND date < (SELECT MAX(date) FROM user_stats) - 1 ",
+ "' ", ifelse(nocutoff == "off",
+ " AND date < (SELECT MAX(date) FROM user_stats) - 1 ", ""),
" AND country = '", ifelse(country == "all", "zy", country), "'",
sep = "")
rs <- dbSendQuery(con, q)
diff --git a/src/org/torproject/ernie/web/GraphParameterChecker.java b/src/org/torproject/ernie/web/GraphParameterChecker.java
index 8189f19..81091e4 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,events,filename,dpi");
+ "start,end,country,events,filename,nocutoff,dpi");
this.availableGraphs.put("bridge-users",
"start,end,country,filename,dpi");
this.availableGraphs.put("gettor", "start,end,language,filename,dpi");
@@ -74,6 +74,7 @@ public class GraphParameterChecker {
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("nocutoff", "on,off");
this.knownParameterValues.put("dpi", "72,150,300");
}
@@ -301,6 +302,26 @@ public class GraphParameterChecker {
}
}
+ /* Parse whether the last day(s) of a time series should be cut off.
+ * This parameter can either be "on" or "off," where "off" is the
+ * default. */
+ if (supportedGraphParameters.contains("nocutoff")) {
+ String[] nocutoffParameter = (String[]) requestParameters.get(
+ "nocutoff");
+ List<String> knownValues = Arrays.asList(
+ this.knownParameterValues.get("nocutoff").split(","));
+ if (nocutoffParameter != null) {
+ if (nocutoffParameter.length != 1 ||
+ nocutoffParameter[0].length() == 0 ||
+ !knownValues.contains(nocutoffParameter[0])) {
+ return null;
+ }
+ } else {
+ nocutoffParameter = new String[] { "off" };
+ }
+ recognizedGraphParameters.put("nocutoff", nocutoffParameter);
+ }
+
/* Parse graph resolution in dpi. The default is 72. */
if (supportedGraphParameters.contains("dpi")) {
String[] dpiParameter = (String[]) requestParameters.get("dpi");
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits