liquid_feedback_core

view lf_export @ 142:54ac8c473263

Use an improved definition for "disqualified" initiatives

"initiative"."disqualified" is TRUE, if the initiative may not win, because it either (a) has no better rank than the status quo, or (b) because there exists a better ranked initiative X, which directly beats this initiative, and either more voters prefer X to this initiative than voters preferring X to the status quo or less voters prefer this initiative to X than voters preferring the status quo to X
author jbe
date Wed Jun 01 16:58:00 2011 +0200 (2011-06-01)
parents 2b03946cb0c2
children
line source
1 #!/bin/sh
3 if [ -z "$1" -o -z "$2" ]; then
4 echo "Usage: $0 <dbname> <filename>.sql.gz"
5 exit 1
6 fi
8 EXPORT_DBNAME=liquid_feedback_autoexport
9 retval=0
11 echo "Dropping database \"$EXPORT_DBNAME\" if existent..."
12 dropdb "$EXPORT_DBNAME" 2> /dev/null
13 echo "Copying database \"$1\" to new database \"$EXPORT_DBNAME\"..."
14 # TODO: use character encoding of original database
15 if (createdb "$EXPORT_DBNAME" && pg_dump "$1" | psql -f - "$EXPORT_DBNAME" > /dev/null)
16 then
17 echo "Deleting private data in copied database..."
18 if psql -v ON_ERROR_STOP=1 -c 'SELECT delete_private_data()' "$EXPORT_DBNAME" > /dev/null
19 then
20 echo "Dumping and compressing copied database to \"$2\"..."
21 if pg_dump --no-owner --no-privileges "$EXPORT_DBNAME" | gzip -9 > "$2"
22 then
23 true
24 else
25 retval=4
26 fi
27 else
28 retval=3
29 fi
30 else
31 retval=2
32 fi
33 echo "Dropping database \"$EXPORT_DBNAME\"..."
34 dropdb "$EXPORT_DBNAME"
35 echo "DONE."
36 exit $retval

Impressum / About Us