From 901e92e9781f8ed6c42029ca12aa486b285e83e5 Mon Sep 17 00:00:00 2001 From: francis Date: Fri, 9 May 2008 00:55:42 +0000 Subject: Graph --- script/request-creation-graph | 103 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100755 script/request-creation-graph (limited to 'script/request-creation-graph') diff --git a/script/request-creation-graph b/script/request-creation-graph new file mode 100755 index 000000000..d5d87063d --- /dev/null +++ b/script/request-creation-graph @@ -0,0 +1,103 @@ +#!/bin/bash +# request-creation-graph +# Plot graph of rate of request creation +# +# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. +# Email: francis@mysociety.org. WWW: http://www.mysociety.org/ +# +# $Id: request-creation-graph,v 1.1 2008-05-09 00:55:43 francis Exp $ + +GPLOT_OUTPUT="set terminal png font 'Vera.ttf' 9 size 1200,400" +EXTENSION=".png" +#GPLOT_OUTPUT="set terminal fig color big thickness 1" +#EXTENSION=".fig" +#GPLOT_OUTPUT="set terminal svg size 800 250" +#EXTENSION=".svg" + +cd `dirname $0` +cd ../../ +source shlib/deployfns + +# XXX this is nasty :) +OPTION_FOI_DB_HOST=`grep "host:" foi/config/database.yml | head --lines=1 | cut -d ":" -f 2` +OPTION_FOI_DB_PORT=`grep "port:" foi/config/database.yml | head --lines=1 | cut -d ":" -f 2` +OPTION_FOI_DB_NAME=`grep "database:" foi/config/database.yml | head --lines=1 | cut -d ":" -f 2` +OPTION_FOI_DB_USER=`grep "username:" foi/config/database.yml | head --lines=1 | cut -d ":" -f 2` + +SOURCEA=/tmp/foi-creation-rate-graph-data-$RANDOM$RANDOM +SOURCEB=/tmp/foi-creation-rate-graph-data-$RANDOM$RANDOM +SOURCEC=/tmp/foi-creation-rate-graph-data-$RANDOM$RANDOM +SOURCED=/tmp/foi-creation-rate-graph-data-$RANDOM$RANDOM +SOURCEE=/tmp/foi-creation-rate-graph-data-$RANDOM$RANDOM +SOURCEF=/tmp/foi-creation-rate-graph-data-$RANDOM$RANDOM +SOURCEG=/tmp/foi-creation-rate-graph-data-$RANDOM$RANDOM +GPSCRIPT=/tmp/foi-creation-rate-graph-script-$RANDOM$RANDOM + +# where status in ('draft') + +function grab_data { + echo "select + date(created_at), count(*) + from info_requests + $1 + group by date(created_at) + order by date(created_at) + ;" | psql --host $OPTION_FOI_DB_HOST --port $OPTION_FOI_DB_PORT -A -F " " $OPTION_FOI_DB_NAME $OPTION_FOI_DB_USER | egrep -v "date|rows" >$2 +} + +# rather nastily, work out the cumulative heights in reverse, so can plot impulses on top of each other +grab_data "" $SOURCEA +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 +grab_data "where described_state not in ('waiting_response', 'waiting_clarification', 'not_held', 'rejected')" $SOURCEE +grab_data "where described_state not in ('waiting_response', 'waiting_clarification', 'not_held', 'rejected', 'successful')" $SOURCEF +grab_data "where described_state not in ('waiting_response', 'waiting_clarification', 'not_held', 'rejected', 'successful', 'partially_successful')" $SOURCEG + + +#state = 'unconfirmed' +#or state = 'confirmed' +#or state = 'fixed' +#or state = 'hidden' +#or state = 'flickr' + + +cat >$GPSCRIPT < foi/public/foi-live-creation$EXTENSION + + -- cgit v1.2.3