liquid_feedback_core

changeset 135:4c3a5d0c4c82

Changed definition/behaviour of "promising" attribute
(see COMMENT ON COLUMN "initiative"."promising")
author jbe
date Wed May 25 09:24:25 2011 +0200 (2011-05-25)
parents bd0cd909189d
children d5f30a515864
files core.sql
line diff
     1.1 --- a/core.sql	Tue May 24 23:35:29 2011 +0200
     1.2 +++ b/core.sql	Wed May 25 09:24:25 2011 +0200
     1.3 @@ -592,7 +592,7 @@
     1.4  COMMENT ON COLUMN "initiative"."eligible"       IS 'TRUE, if initiative is "attainable" and "favored"';
     1.5  COMMENT ON COLUMN "initiative"."rank"           IS 'Schulze-Ranking after tie-breaking';
     1.6  COMMENT ON COLUMN "initiative"."winner"         IS 'TRUE, if initiative is final winner (best ranked initiative being "eligible")';
     1.7 -COMMENT ON COLUMN "initiative"."promising"      IS 'TRUE, if initiative would win against current winner, when voting is repeated with ballots based on same preferences. Non "attainable" initiatives may never be "winner", but they can be "promising".';
     1.8 +COMMENT ON COLUMN "initiative"."promising"      IS 'TRUE, if and only if this initiative is not a winner and there is a number n>0, such that repeating the calculation of the winner n times with the previous winner as status quo causes this initiative to win. The calculations use the same preferences and include the previous status quo as an explicit option. Non "attainable" initiatives may never be "winner", but they can be "promising".';
     1.9  
    1.10  
    1.11  CREATE TABLE "battle" (
    1.12 @@ -3835,9 +3835,8 @@
    1.13          UPDATE "initiative" SET "winner" = TRUE WHERE "id" = "initiative_id_v";
    1.14          -- determine promising initiatives:
    1.15          LOOP
    1.16 -          "promising_added_v" := FALSE;
    1.17 -          FOR "initiative_id_v" IN
    1.18 -            SELECT "new_initiative"."id"
    1.19 +          -- NOTE: non-straightened ranks are used
    1.20 +          SELECT "new_initiative"."id" INTO "initiative_id_v"
    1.21              FROM "issue"
    1.22              JOIN "policy" ON "issue"."policy_id" = "policy"."id"
    1.23              JOIN "initiative" "old_initiative"
    1.24 @@ -3847,6 +3846,7 @@
    1.25              JOIN "initiative" "new_initiative"
    1.26                ON "new_initiative"."issue_id" = "issue_id_p"
    1.27                AND "new_initiative"."admitted"
    1.28 +              AND "new_initiative"."favored"
    1.29                AND NOT ("new_initiative"."winner" OR "new_initiative"."promising")
    1.30              JOIN "battle" "battle_win"
    1.31                ON "battle_win"."issue_id" = "issue_id_p"
    1.32 @@ -3858,7 +3858,6 @@
    1.33                AND "battle_lose"."winning_initiative_id" = "old_initiative"."id"
    1.34              WHERE "issue"."id" = "issue_id_p"
    1.35              AND "new_initiative"."rank" < "old_initiative"."rank"
    1.36 -            -- NOTE: non-straightened ranks are used
    1.37              AND CASE WHEN "policy"."majority_strict" THEN
    1.38                "battle_win"."count" * "policy"."majority_den" >
    1.39                "policy"."majority_num" *
    1.40 @@ -3868,12 +3867,14 @@
    1.41                "policy"."majority_num" *
    1.42                ("battle_win"."count"+"battle_lose"."count")
    1.43              END
    1.44 -          LOOP
    1.45 +            ORDER BY "new_initiative"."rank"
    1.46 +            LIMIT 1;
    1.47 +          IF FOUND THEN
    1.48              UPDATE "initiative" SET "promising" = TRUE
    1.49                WHERE "id" = "initiative_id_v";
    1.50 -            "promising_added_v" := TRUE;
    1.51 -          END LOOP;
    1.52 -          EXIT WHEN NOT "promising_added_v";
    1.53 +          ELSE
    1.54 +            EXIT;
    1.55 +          END IF;
    1.56          END LOOP;
    1.57          -- straighten ranks (start counting with 1, no equal ranks):
    1.58          "rank_v" := 1;

Impressum / About Us