aboutsummaryrefslogtreecommitdiffstats
path: root/script/request-creation-graph
diff options
context:
space:
mode:
Diffstat (limited to 'script/request-creation-graph')
-rwxr-xr-xscript/request-creation-graph12
1 files changed, 7 insertions, 5 deletions
diff --git a/script/request-creation-graph b/script/request-creation-graph
index 7d347a7d2..9b91e44b9 100755
--- a/script/request-creation-graph
+++ b/script/request-creation-graph
@@ -17,11 +17,7 @@ cd `dirname $0`
cd ../
source commonlib/shlib/deployfns
-# TODO: this is nasty :)
-OPTION_FOI_DB_HOST=`grep "host:" config/database.yml | head --lines=1 | cut -d ":" -f 2`
-OPTION_FOI_DB_PORT=`grep "port:" config/database.yml | head --lines=1 | cut -d ":" -f 2`
-OPTION_FOI_DB_NAME=`grep "database:" config/database.yml | head --lines=1 | cut -d ":" -f 2`
-OPTION_FOI_DB_USER=`grep "username:" config/database.yml | head --lines=1 | cut -d ":" -f 2`
+read OPTION_FOI_DB_HOST OPTION_FOI_DB_PORT OPTION_FOI_DB_NAME OPTION_FOI_DB_USER <<<$(ruby -r yaml -e 'db = YAML::load(STDIN.read); pr = db["production"]; puts pr["host"], pr["port"], pr["database"], pr["username"]' < config/database.yml)
SOURCEA=/tmp/foi-creation-rate-graph-data-$RANDOM$RANDOM
SOURCEB=/tmp/foi-creation-rate-graph-data-$RANDOM$RANDOM
@@ -51,6 +47,12 @@ function grab_data {
# rather nastily, work out the cumulative heights in reverse, so can plot impulses on top of each other
grab_data "where (1 = 1)" $SOURCEA
+if [ ! -s $SOURCEA ] ; then
+ # No data yet, skip graphing
+ echo "warning: no data to graph, skipping task"
+ exit
+fi
+
grab_data "where described_state not in ('waiting_response')" $SOURCEB
grab_data "where described_state not in ('waiting_response', 'waiting_clarification')" $SOURCEC
grab_data "where described_state not in ('waiting_response', 'waiting_clarification', 'not_held')" $SOURCED