[metrics-db/master] Make refresh script part of the database schema.
Mon Feb 28 22:06:02 UTC 2011
commit e41b07580bc556a50208756d6d2f580e550ccf31
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Fri Jan 14 11:09:53 2011 +0100
Make refresh script part of the database schema.
---
db/refresh.sql | 24 ------------------------
db/tordir.sql | 17 +++++++++++++++++
2 files changed, 17 insertions(+), 24 deletions(-)
diff --git a/db/refresh.sql b/db/refresh.sql
deleted file mode 100644
index ce732c4..0000000
--- a/db/refresh.sql
+++ /dev/null
@@ -1,24 +0,0 @@
--- Copyright 2010 The Tor Project
--- See LICENSE for licensing information
-
--- REFRESH.SQL
--- This script should be run every time ernie is run to keep data sinks
--- up to date by calling the refresh functions.
-
--- Make this script a transaction, in case we need to roll-back changes.
-BEGIN;
-
-SELECT * FROM refresh_relay_statuses_per_day();
-SELECT * FROM refresh_network_size();
-SELECT * FROM refresh_network_size_hour();
-SELECT * FROM refresh_relay_platforms();
-SELECT * FROM refresh_relay_versions();
-SELECT * FROM refresh_total_bandwidth();
-SELECT * FROM refresh_total_bwhist();
-SELECT * FROM refresh_user_stats();
-
--- Clear the updates table, since we have just updated everything.
-DELETE FROM updates;
-
--- Commit the transaction.
-COMMIT;
diff --git a/db/tordir.sql b/db/tordir.sql
index 40afb32..a69ddba 100644
--- a/db/tordir.sql
+++ b/db/tordir.sql
@@ -806,3 +806,20 @@ CREATE TABLE gettor_stats (
CONSTRAINT gettor_stats_pkey PRIMARY KEY("date", bundle)
);
+-- FUNCTION refresh_all()
+-- This function refreshes all statistics in the database.
+CREATE OR REPLACE FUNCTION refresh_all() RETURNS INTEGER AS $$
+ BEGIN
+ PERFORM refresh_relay_statuses_per_day();
+ PERFORM refresh_network_size();
+ PERFORM refresh_network_size_hour();
+ PERFORM refresh_relay_platforms();
+ PERFORM refresh_relay_versions();
+ PERFORM refresh_total_bandwidth();
+ PERFORM refresh_total_bwhist();
+ PERFORM refresh_user_stats();
+ DELETE FROM updates;
+ RETURN 1;
+ END;
+$$ LANGUAGE plpgsql;
+
More information about the tor-commits
mailing list