liquid_feedback_core
changeset 143:9d78380d1974
Added columns "majority_positive" and "majority_non_negative" to table "policy",
allowing an absolute number of (positive or non-negative) votes to be required for an initiative to be attainable as winner.
allowing an absolute number of (positive or non-negative) votes to be required for an initiative to be attainable as winner.
author | jbe |
---|---|
date | Wed Jun 01 18:03:22 2011 +0200 (2011-06-01) |
parents | 54ac8c473263 |
children | 259dd3e127c0 |
files | core.sql |
line diff
1.1 --- a/core.sql Wed Jun 01 16:58:00 2011 +0200 1.2 +++ b/core.sql Wed Jun 01 18:03:22 2011 +0200 1.3 @@ -310,7 +310,9 @@ 1.4 "initiative_quorum_den" INT4 NOT NULL, 1.5 "majority_num" INT4 NOT NULL DEFAULT 1, 1.6 "majority_den" INT4 NOT NULL DEFAULT 2, 1.7 - "majority_strict" BOOLEAN NOT NULL DEFAULT TRUE ); 1.8 + "majority_strict" BOOLEAN NOT NULL DEFAULT TRUE, 1.9 + "majority_positive" INT4 NOT NULL DEFAULT 0, 1.10 + "majority_non_negative" INT4 NOT NULL DEFAULT 0 ); 1.11 CREATE INDEX "policy_active_idx" ON "policy" ("active"); 1.12 1.13 COMMENT ON TABLE "policy" IS 'Policies for a particular proceeding type (timelimits, quorum)'; 1.14 @@ -325,9 +327,11 @@ 1.15 COMMENT ON COLUMN "policy"."issue_quorum_den" IS 'Denominator of potential supporter quorum to be reached by one initiative of an issue to be "accepted"'; 1.16 COMMENT ON COLUMN "policy"."initiative_quorum_num" IS 'Numerator of satisfied supporter quorum to be reached by an initiative to be "admitted" for voting'; 1.17 COMMENT ON COLUMN "policy"."initiative_quorum_den" IS 'Denominator of satisfied supporter quorum to be reached by an initiative to be "admitted" for voting'; 1.18 -COMMENT ON COLUMN "policy"."majority_num" IS 'Numerator of fraction of majority to be reached during voting by an initiative to be aggreed upon'; 1.19 -COMMENT ON COLUMN "policy"."majority_den" IS 'Denominator of fraction of majority to be reached during voting by an initiative to be aggreed upon'; 1.20 +COMMENT ON COLUMN "policy"."majority_num" IS 'Numerator of fraction of majority to be reached during voting by an initiative to be "attainable"'; 1.21 +COMMENT ON COLUMN "policy"."majority_den" IS 'Denominator of fraction of majority to be reached during voting by an initiative to be "attainable"'; 1.22 COMMENT ON COLUMN "policy"."majority_strict" IS 'If TRUE, then the majority must be strictly greater than "majority_num"/"majority_den", otherwise it may also be equal.'; 1.23 +COMMENT ON COLUMN "policy"."majority_positive" IS 'Absolute number of "positive_votes" neccessary for an initiative to be "attainable".'; 1.24 +COMMENT ON COLUMN "policy"."majority_non_negative" IS 'Absolute number of sum of "positive_votes" and abstentions neccessary for an initiative to be "attainable".'; 1.25 1.26 1.27 CREATE TABLE "unit" ( 1.28 @@ -579,7 +583,7 @@ 1.29 COMMENT ON COLUMN "initiative"."satisfied_informed_supporter_count" IS 'Calculated from table "direct_supporter_snapshot"'; 1.30 COMMENT ON COLUMN "initiative"."positive_votes" IS 'Calculated from table "direct_voter"'; 1.31 COMMENT ON COLUMN "initiative"."negative_votes" IS 'Calculated from table "direct_voter"'; 1.32 -COMMENT ON COLUMN "initiative"."attainable" IS 'TRUE, if "positive_votes"/("positive_votes"+"negative_votes") is strictly greater or greater-equal than "majority_num"/"majority_den"'; 1.33 +COMMENT ON COLUMN "initiative"."attainable" IS 'TRUE, if "positive_votes"/("positive_votes"+"negative_votes") is strictly greater or greater-equal than "majority_num"/"majority_den", and "positive_votes" is greater-equal than "majority_positive", and ("positive_votes"+abstentions) is greater-equal than "majority_non_negative"'; 1.34 COMMENT ON COLUMN "initiative"."favored" IS 'TRUE, if initiative has a schulze-ranking better than the status quo (without tie-breaking)'; 1.35 COMMENT ON COLUMN "initiative"."unfavored" IS 'TRUE, if initiative has a schulze-ranking worse than the status quo (without tie-breaking)'; 1.36 COMMENT ON COLUMN "initiative"."preliminary_rank" IS 'Schulze-Ranking without tie-breaking'; 1.37 @@ -3528,15 +3532,19 @@ 1.38 UPDATE "initiative" SET 1.39 "positive_votes" = "vote_counts"."positive_votes", 1.40 "negative_votes" = "vote_counts"."negative_votes", 1.41 - "attainable" = CASE WHEN "majority_strict" THEN 1.42 - "vote_counts"."positive_votes" * "majority_den" > 1.43 - "majority_num" * 1.44 - ("vote_counts"."positive_votes"+"vote_counts"."negative_votes") 1.45 - ELSE 1.46 - "vote_counts"."positive_votes" * "majority_den" >= 1.47 - "majority_num" * 1.48 - ("vote_counts"."positive_votes"+"vote_counts"."negative_votes") 1.49 - END 1.50 + "attainable" = 1.51 + CASE WHEN "majority_strict" THEN 1.52 + "vote_counts"."positive_votes" * "majority_den" > 1.53 + "majority_num" * 1.54 + ("vote_counts"."positive_votes"+"vote_counts"."negative_votes") 1.55 + ELSE 1.56 + "vote_counts"."positive_votes" * "majority_den" >= 1.57 + "majority_num" * 1.58 + ("vote_counts"."positive_votes"+"vote_counts"."negative_votes") 1.59 + END 1.60 + AND "vote_counts"."positive_votes" >= "policy"."majority_positive" 1.61 + AND "issue"."voter_count"-"vote_counts"."negative_votes" >= 1.62 + "policy"."majority_non_negative" 1.63 FROM 1.64 ( SELECT 1.65 "initiative"."id" AS "initiative_id",