#!/bin/bash # request-creation-graph # Plot graph of rate of request creation # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: hello@mysociety.org. WWW: http://www.mysociety.org/ GPLOT_OUTPUT="set terminal png font 'Vera.ttf' 9 size 1600,600" EXTENSION=".png" LW=4 #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 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` 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 SOURCEH=/tmp/foi-creation-rate-graph-data-$RANDOM$RANDOM SOURCEI=/tmp/foi-creation-rate-graph-data-$RANDOM$RANDOM SOURCEJ=/tmp/foi-creation-rate-graph-data-$RANDOM$RANDOM SOURCEK=/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 and prominence != 'backpage' 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 "where (1 = 1)" $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 grab_data "where described_state not in ('waiting_response', 'waiting_clarification', 'not_held', 'rejected', 'successful', 'partially_successful', 'requires_admin')" $SOURCEH grab_data "where described_state not in ('waiting_response', 'waiting_clarification', 'not_held', 'rejected', 'successful', 'partially_successful', 'requires_admin', 'gone_postal')" $SOURCEI grab_data "where described_state not in ('waiting_response', 'waiting_clarification', 'not_held', 'rejected', 'successful', 'partially_successful', 'requires_admin', 'gone_postal', 'internal_review')" $SOURCEJ grab_data "where described_state not in ('waiting_response', 'waiting_clarification', 'not_held', 'rejected', 'successful', 'partially_successful', 'requires_admin', 'gone_postal', 'internal_review', 'error_message')" $SOURCEK #user_withdrawn cat >$GPSCRIPT < public/foi-live-creation$EXTENSION