[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-web/master] Remove remains of hourly relay flags graph.
commit 124a4d91f0b7ac649db16a85e44d8e29c5dd179b
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Fri Feb 1 12:40:29 2013 +0100
Remove remains of hourly relay flags graph.
Hourly relay flags graphs were disabled seven weeks ago as part of #7652.
Remove the remaining, now unused code.
---
db/tordir.sql | 45 ---------
rserve/csv.R | 14 ---
rserve/graphs.R | 98 +++++++-------------
.../ernie/web/graphs/GraphParameterChecker.java | 20 ----
.../ernie/web/graphs/RObjectGenerator.java | 3 +-
5 files changed, 36 insertions(+), 144 deletions(-)
diff --git a/db/tordir.sql b/db/tordir.sql
index 3749774..571a324 100644
--- a/db/tordir.sql
+++ b/db/tordir.sql
@@ -157,17 +157,6 @@ CREATE TABLE network_size (
CONSTRAINT network_size_pkey PRIMARY KEY(date)
);
--- TABLE network_size_hour
-CREATE TABLE network_size_hour (
- validafter TIMESTAMP WITHOUT TIME ZONE NOT NULL,
- avg_running INTEGER NOT NULL,
- avg_exit INTEGER NOT NULL,
- avg_guard INTEGER NOT NULL,
- avg_fast INTEGER NOT NULL,
- avg_stable INTEGER NOT NULL,
- CONSTRAINT network_size_hour_pkey PRIMARY KEY(validafter)
-);
-
-- TABLE relay_countries
CREATE TABLE relay_countries (
date DATE NOT NULL,
@@ -436,38 +425,6 @@ CREATE OR REPLACE FUNCTION refresh_network_size() RETURNS INTEGER AS $$
END;
$$ LANGUAGE plpgsql;
--- FUNCTION refresh_network_size_hour()
-CREATE OR REPLACE FUNCTION refresh_network_size_hour() RETURNS INTEGER AS $$
- DECLARE
- min_date TIMESTAMP WITHOUT TIME ZONE;
- max_date TIMESTAMP WITHOUT TIME ZONE;
- BEGIN
-
- min_date := (SELECT MIN(date) FROM updates);
- max_date := (SELECT MAX(date) + 1 FROM updates);
-
- DELETE FROM network_size_hour
- WHERE DATE(validafter) IN (SELECT date FROM updates);
-
- EXECUTE '
- INSERT INTO network_size_hour
- (validafter, avg_running, avg_exit, avg_guard, avg_fast, avg_stable)
- SELECT validafter, COUNT(*) AS avg_running,
- COUNT(NULLIF(isexit, FALSE)) AS avg_exit,
- COUNT(NULLIF(isguard, FALSE)) AS avg_guard,
- COUNT(NULLIF(isfast, FALSE)) AS avg_fast,
- COUNT(NULLIF(isstable, FALSE)) AS avg_stable
- FROM statusentry
- WHERE isrunning = TRUE
- AND validafter >= ''' || min_date || '''
- AND validafter < ''' || max_date || '''
- AND DATE(validafter) IN (SELECT date FROM updates)
- GROUP BY validafter';
-
- RETURN 1;
- END;
-$$ LANGUAGE plpgsql;
-
-- FUNCTION refresh_relay_countries()
CREATE OR REPLACE FUNCTION refresh_relay_countries() RETURNS INTEGER AS $$
DECLARE
@@ -953,8 +910,6 @@ CREATE OR REPLACE FUNCTION refresh_all() RETURNS INTEGER AS $$
PERFORM refresh_relay_statuses_per_day();
RAISE NOTICE '% Refreshing network size.', timeofday();
PERFORM refresh_network_size();
- RAISE NOTICE '% Refreshing hourly network size.', timeofday();
- PERFORM refresh_network_size_hour();
RAISE NOTICE '% Refreshing relays by country.', timeofday();
PERFORM refresh_relay_countries();
RAISE NOTICE '% Refreshing relay platforms.', timeofday();
diff --git a/rserve/csv.R b/rserve/csv.R
index d7917e0..f8c21b1 100644
--- a/rserve/csv.R
+++ b/rserve/csv.R
@@ -135,20 +135,6 @@ export_relayflags <- function(path) {
write.csv(relayflags, path, quote = FALSE, row.names = FALSE)
}
-export_relayflags_hour <- function(path) {
- drv <- dbDriver("PostgreSQL")
- con <- dbConnect(drv, user = dbuser, password = dbpassword, dbname = db)
- q <- paste("SELECT validafter, avg_running AS running,",
- "avg_exit AS exit, avg_guard AS guard, avg_fast AS fast,",
- "avg_stable AS stable FROM network_size_hour",
- "WHERE DATE(validafter) < current_date - 1 ORDER BY validafter")
- rs <- dbSendQuery(con, q)
- relayflags <- fetch(rs, n = -1)
- dbDisconnect(con)
- dbUnloadDriver(drv)
- write.csv(relayflags, path, quote = FALSE, row.names = FALSE)
-}
-
export_direct_users <- function(path) {
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, user = dbuser, password = dbpassword, dbname = db)
diff --git a/rserve/graphs.R b/rserve/graphs.R
index 07de07f..22225be 100644
--- a/rserve/graphs.R
+++ b/rserve/graphs.R
@@ -591,76 +591,48 @@ plot_dirbytes <- function(start, end, path) {
ggsave(filename = path, width = 8, height = 5, dpi = 72)
}
-plot_relayflags <- function(start, end, flags, granularity, path) {
+plot_relayflags <- function(start, end, flags, path) {
end <- min(end, as.character(Sys.Date() - 2))
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, user = dbuser, password = dbpassword, dbname = db)
- if (granularity == 'day') {
- columns <- paste("avg_", tolower(flags), sep = "", collapse = ", ")
- q <- paste("SELECT date, ", columns, " FROM network_size ",
- "WHERE date >= '", start, "' AND date <= '", end, "'", sep = "")
- rs <- dbSendQuery(con, q)
- networksize <- fetch(rs, n = -1)
- dbDisconnect(con)
- dbUnloadDriver(drv)
- networksize <- melt(networksize, id = "date")
+ columns <- paste("avg_", tolower(flags), sep = "", collapse = ", ")
+ q <- paste("SELECT date, ", columns, " FROM network_size ",
+ "WHERE date >= '", start, "' AND date <= '", end, "'", sep = "")
+ rs <- dbSendQuery(con, q)
+ networksize <- fetch(rs, n = -1)
+ dbDisconnect(con)
+ dbUnloadDriver(drv)
+ networksize <- melt(networksize, id = "date")
+ networksize <- rbind(data.frame(
+ date = as.Date(end) + 1,
+ variable = paste("avg_", c("running", "exit", "guard", "fast",
+ "stable"), sep = ""),
+ value = NA), networksize)
+ dates <- seq(from = as.Date(start, "%Y-%m-%d"),
+ to = as.Date(end, "%Y-%m-%d"), by="1 day")
+ missing <- setdiff(dates, networksize$date)
+ if (length(missing) > 0)
networksize <- rbind(data.frame(
- date = as.Date(end) + 1,
+ date = as.Date(rep(missing, 5), origin = "1970-01-01"),
variable = paste("avg_", c("running", "exit", "guard", "fast",
"stable"), sep = ""),
- value = NA), networksize)
- dates <- seq(from = as.Date(start, "%Y-%m-%d"),
- to = as.Date(end, "%Y-%m-%d"), by="1 day")
- missing <- setdiff(dates, networksize$date)
- if (length(missing) > 0)
- networksize <- rbind(data.frame(
- date = as.Date(rep(missing, 5), origin = "1970-01-01"),
- variable = paste("avg_", c("running", "exit", "guard", "fast",
- "stable"), sep = ""),
- value = rep(NA, length(missing) * 5)), networksize)
- date_breaks <- date_breaks(
- as.numeric(max(as.Date(end, "%Y-%m-%d")) -
- min(as.Date(networksize$date, "%Y-%m-%d"))))
- ggplot(networksize, aes(x = as.Date(date, "%Y-%m-%d"), y = value,
- colour = as.factor(variable))) + geom_line(size = 1) +
- scale_x_date(name = paste("\nThe Tor Project - ",
- "https://metrics.torproject.org/", sep = ""),
+ value = rep(NA, length(missing) * 5)), networksize)
+ date_breaks <- date_breaks(
+ as.numeric(max(as.Date(end, "%Y-%m-%d")) -
+ min(as.Date(networksize$date, "%Y-%m-%d"))))
+ ggplot(networksize, aes(x = as.Date(date, "%Y-%m-%d"), y = value,
+ colour = as.factor(variable))) + geom_line(size = 1) +
+ scale_x_date(name = paste("\nThe Tor Project - ",
+ "https://metrics.torproject.org/", sep = ""),
format = date_breaks$format, major = date_breaks$major,
- minor = date_breaks$minor, limits = as.Date(c(start, end))) +
- scale_y_continuous(name = "", limits = c(0, max(networksize$value,
- na.rm = TRUE))) +
- scale_colour_manual(name = "Relay flags", values = c("#E69F00",
- "#56B4E9", "#009E73", "#000000", "#0072B2"),
- breaks = paste("avg_", tolower(flags), sep = ""),
- labels = flags) +
- opts(title = "Number of relays with relay flags assigned\n")
- } else {
- columns <- paste("avg_", tolower(flags), sep = "", collapse = ", ")
- q <- paste("SELECT validafter, ", columns, " FROM network_size_hour ",
- "WHERE DATE(validafter) >= '", start,
- "' AND DATE(validafter) <= '", end, "'", sep = "")
- rs <- dbSendQuery(con, q)
- networksize <- fetch(rs, n = -1)
- dbDisconnect(con)
- dbUnloadDriver(drv)
- networksize <- melt(networksize, id = "validafter")
- networksize <- rbind(data.frame(
- validafter = as.POSIXct(rep(paste(end, "23:59:00"), 5)),
- variable = paste("avg_", c("running", "exit", "guard", "fast",
- "stable"), sep = ""),
- value = rep(NA, 5)), networksize)
- ggplot(networksize, aes(x = as.POSIXct(validafter), y = value,
- colour = variable)) + geom_line(size = 1) +
- scale_x_datetime(name = paste("\nThe Tor Project - ",
- "https://metrics.torproject.org/", sep = "")) +
- scale_y_continuous(name = "", limits = c(0, max(networksize$value,
- na.rm = TRUE))) +
- scale_colour_manual(name = "Relay flags", values = c("#E69F00",
- "#56B4E9", "#009E73", "#000000", "#0072B2"),
- breaks = paste("avg_", tolower(flags), sep = ""),
- labels = flags) +
- opts(title = "Number of relays with relay flags assigned\n")
- }
+ minor = date_breaks$minor, limits = as.Date(c(start, end))) +
+ scale_y_continuous(name = "", limits = c(0, max(networksize$value,
+ na.rm = TRUE))) +
+ scale_colour_manual(name = "Relay flags", values = c("#E69F00",
+ "#56B4E9", "#009E73", "#000000", "#0072B2"),
+ breaks = paste("avg_", tolower(flags), sep = ""),
+ labels = flags) +
+ opts(title = "Number of relays with relay flags assigned\n")
ggsave(filename = path, width = 8, height = 5, dpi = 72)
}
diff --git a/src/org/torproject/ernie/web/graphs/GraphParameterChecker.java b/src/org/torproject/ernie/web/graphs/GraphParameterChecker.java
index c22a845..a47538e 100644
--- a/src/org/torproject/ernie/web/graphs/GraphParameterChecker.java
+++ b/src/org/torproject/ernie/web/graphs/GraphParameterChecker.java
@@ -50,7 +50,6 @@ public class GraphParameterChecker {
this.knownParameterValues = new HashMap<String, String>();
this.knownParameterValues.put("flag",
"Running,Exit,Guard,Fast,Stable");
- this.knownParameterValues.put("granularity", "day");
StringBuilder sb = new StringBuilder("all");
for (String[] country : Countries.getInstance().getCountryList()) {
sb.append("," + country[0]);
@@ -148,25 +147,6 @@ public class GraphParameterChecker {
recognizedGraphParameters.put("flag", flagParameters);
}
- /* Parse granularity, which can be 1 day or 1 hour, if supported by
- * the graph type. The default is 1 day. */
- if (supportedGraphParameters.contains("granularity")) {
- String[] granularityParameter = (String[]) requestParameters.get(
- "granularity");
- List<String> knownGranularities = Arrays.asList(
- this.knownParameterValues.get("granularity").split(","));
- if (granularityParameter != null) {
- if (granularityParameter.length != 1 ||
- granularityParameter[0] == null ||
- !knownGranularities.contains(granularityParameter[0])) {
- return null;
- }
- } else {
- granularityParameter = new String[] { "day" };
- }
- recognizedGraphParameters.put("granularity", granularityParameter);
- }
-
/* Parse country codes if supported by the graph type. If no countries
* are passed, use country code "all" (all countries) as default. */
if (supportedGraphParameters.contains("country")) {
diff --git a/src/org/torproject/ernie/web/graphs/RObjectGenerator.java b/src/org/torproject/ernie/web/graphs/RObjectGenerator.java
index c4eb801..6ed77f2 100644
--- a/src/org/torproject/ernie/web/graphs/RObjectGenerator.java
+++ b/src/org/torproject/ernie/web/graphs/RObjectGenerator.java
@@ -87,8 +87,7 @@ public class RObjectGenerator implements ServletContextListener {
this.availableGraphs.put("cloudbridges", "start,end,filename");
this.availableGraphs.put("relaycountries",
"start,end,country,filename");
- this.availableGraphs.put("relayflags", "start,end,flag,granularity,"
- + "filename");
+ this.availableGraphs.put("relayflags", "start,end,flag,filename");
this.availableGraphs.put("versions", "start,end,filename");
this.availableGraphs.put("platforms", "start,end,filename");
this.availableGraphs.put("bandwidth", "start,end,filename");
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits