#!/bin/bash # user-use-graph # Plot graph of user use of site. # # Copyright (c) 2009 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 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 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 GPSCRIPT=/tmp/foi-creation-rate-graph-script-$RANDOM$RANDOM # where status in ('draft') function grab_data { echo "$1;" | 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 "select date(created_at), count (distinct user_id) from info_requests group by date(created_at) order by date(created_at)" $SOURCEA grab_data "select date(created_at), count(*) from users group by date(created_at) order by date(created_at)" $SOURCEB grab_data "select date(created_at), count(*) from users where email_confirmed = 't' group by date(created_at) order by date(created_at)" $SOURCEC #state = 'unconfirmed' #or state = 'confirmed' #or state = 'fixed' #or state = 'hidden' #or state = 'flickr' cat >$GPSCRIPT < public/foi-user-use$EXTENSION