liquid_feedback_core
annotate lf_export @ 126:5edfb00d840a
Implementation of Schulze's Supermajority Requirements
Changes in detail:
- Renamed column "agreed" of table "initiative" to "majority"
- Added column "winner" to table "initiative"
- Extended constraint "non_admitted_initiatives_cant_contain_voting_results" of table "initiative" to "rank" and "winner" columns
- Removed constraint "non_agreed_initiatives_cant_get_a_rank" from table "initiative"
- Replaced PRIMARY KEY of "battle" table by a single NOT NULL constraint on column "issue_id" and three (partial) indicies allowing NULL values as initiative ids
- Added constraint "initiative_ids_not_equal" to "battle" table
- Added view "battle_participant" which selects admitted initiatives plus one virtual "status-quo" initiative for each issue denoted by an initiative_id being NULL
- Modified "battle_view" to include all admitted initiatives plus the virtual "status-quo" initiative
- Modified function "calculate_ranks" to respect all battle participants, to set the rank of all initiatives where the rank is better than status-quo, and to mark the final winner (if existent)
Changes in detail:
- Renamed column "agreed" of table "initiative" to "majority"
- Added column "winner" to table "initiative"
- Extended constraint "non_admitted_initiatives_cant_contain_voting_results" of table "initiative" to "rank" and "winner" columns
- Removed constraint "non_agreed_initiatives_cant_get_a_rank" from table "initiative"
- Replaced PRIMARY KEY of "battle" table by a single NOT NULL constraint on column "issue_id" and three (partial) indicies allowing NULL values as initiative ids
- Added constraint "initiative_ids_not_equal" to "battle" table
- Added view "battle_participant" which selects admitted initiatives plus one virtual "status-quo" initiative for each issue denoted by an initiative_id being NULL
- Modified "battle_view" to include all admitted initiatives plus the virtual "status-quo" initiative
- Modified function "calculate_ranks" to respect all battle participants, to set the rank of all initiatives where the rank is better than status-quo, and to mark the final winner (if existent)
author | jbe |
---|---|
date | Tue May 24 03:01:49 2011 +0200 (2011-05-24) |
parents | 2b03946cb0c2 |
children |
rev | line source |
---|---|
jbe@8 | 1 #!/bin/sh |
jbe@8 | 2 |
jbe@8 | 3 if [ -z "$1" -o -z "$2" ]; then |
jbe@8 | 4 echo "Usage: $0 <dbname> <filename>.sql.gz" |
jbe@8 | 5 exit 1 |
jbe@8 | 6 fi |
jbe@8 | 7 |
jbe@8 | 8 EXPORT_DBNAME=liquid_feedback_autoexport |
jbe@8 | 9 retval=0 |
jbe@8 | 10 |
jbe@8 | 11 echo "Dropping database \"$EXPORT_DBNAME\" if existent..." |
jbe@8 | 12 dropdb "$EXPORT_DBNAME" 2> /dev/null |
jbe@8 | 13 echo "Copying database \"$1\" to new database \"$EXPORT_DBNAME\"..." |
jbe@40 | 14 # TODO: use character encoding of original database |
jbe@40 | 15 if (createdb "$EXPORT_DBNAME" && pg_dump "$1" | psql -f - "$EXPORT_DBNAME" > /dev/null) |
jbe@8 | 16 then |
jbe@8 | 17 echo "Deleting private data in copied database..." |
jbe@9 | 18 if psql -v ON_ERROR_STOP=1 -c 'SELECT delete_private_data()' "$EXPORT_DBNAME" > /dev/null |
jbe@8 | 19 then |
jbe@8 | 20 echo "Dumping and compressing copied database to \"$2\"..." |
jbe@8 | 21 if pg_dump --no-owner --no-privileges "$EXPORT_DBNAME" | gzip -9 > "$2" |
jbe@8 | 22 then |
jbe@11 | 23 true |
jbe@8 | 24 else |
jbe@8 | 25 retval=4 |
jbe@8 | 26 fi |
jbe@8 | 27 else |
jbe@8 | 28 retval=3 |
jbe@8 | 29 fi |
jbe@8 | 30 else |
jbe@8 | 31 retval=2 |
jbe@8 | 32 fi |
jbe@8 | 33 echo "Dropping database \"$EXPORT_DBNAME\"..." |
jbe@8 | 34 dropdb "$EXPORT_DBNAME" |
jbe@8 | 35 echo "DONE." |
jbe@8 | 36 exit $retval |