liquid_feedback_core
view update/core-update.v2.2.5-v2.2.6.sql @ 409:5f24058af0b8
Secondary sorting key for issues in admission phase
| author | jbe | 
|---|---|
| date | Mon Oct 14 00:58:38 2013 +0200 (2013-10-14) | 
| parents | f7b4457cf1a6 | 
| children | d301dc24b25c | 
 line source
     1 BEGIN;
     3 CREATE OR REPLACE VIEW "liquid_feedback_version" AS
     4   SELECT * FROM (VALUES ('2.2.6', 2, 2, 6))
     5   AS "subquery"("string", "major", "minor", "revision");
     7 CREATE TABLE "issue_order" (
     8         "id"                    INT8            PRIMARY KEY, --REFERENCES "issue" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
     9         "order_in_admission_state" INT4,
    10         "max_supporter_count"   INT4 );
    12 COMMENT ON TABLE "issue_order" IS 'Ordering information for issues that are not stored in the "issue" table to avoid locking of multiple issues at once';
    14 COMMENT ON COLUMN "issue_order"."id"                       IS 'References "issue" ("id") but has no referential integrity trigger associated, due to performance/locking issues';
    15 COMMENT ON COLUMN "issue_order"."order_in_admission_state" IS 'To be used for sorting issues within an area, when showing issues in admission state; NULL values sort last; updated by "lf_update_issue_order"';
    16 COMMENT ON COLUMN "issue_order"."max_supporter_count"      IS 'Secondary sorting key when displaying issues in admission state from different areas';
    18 CREATE VIEW "issue_supporter_in_admission_state" AS
    19   SELECT DISTINCT
    20     "issue"."area_id",
    21     "issue"."id" AS "issue_id",
    22     "supporter"."member_id",
    23     "direct_interest_snapshot"."weight"
    24   FROM "issue"
    25   JOIN "supporter" ON "supporter"."issue_id" = "issue"."id"
    26   JOIN "direct_interest_snapshot"
    27     ON  "direct_interest_snapshot"."issue_id" = "issue"."id"
    28     AND "direct_interest_snapshot"."event" = "issue"."latest_snapshot_event"
    29     AND "direct_interest_snapshot"."member_id" = "supporter"."member_id"
    30   WHERE "issue"."state" = 'admission'::"issue_state";
    32 COMMENT ON VIEW "issue_supporter_in_admission_state" IS 'Helper view for "lf_update_issue_order" to allow a (proportional) ordering of issues within an area';
    34 COMMIT;
