
jbe@396: BEGIN;
jbe@396: 
jbe@396: CREATE OR REPLACE VIEW "liquid_feedback_version" AS
jbe@396:   SELECT * FROM (VALUES ('2.2.6', 2, 2, 6))
jbe@396:   AS "subquery"("string", "major", "minor", "revision");
jbe@396: 
jbe@396: ALTER TABLE "issue" ADD COLUMN "order_in_admission_state" INT4;
jbe@396: ALTER TABLE "issue" ADD COLUMN "order_in_open_states"     INT4;
jbe@396: 
jbe@396: COMMENT ON COLUMN "issue"."order_in_admission_state" IS 'To be used for sorting issues within an area, when showing only issues in admission state; NULL values sort last; updated by "lf_update_issue_order"';
jbe@396: COMMENT ON COLUMN "issue"."order_in_open_states"     IS 'To be used for sorting issues within an area, when showing all open issues; NULL values sort last; updated by "lf_update_issue_order"';
jbe@396: 
jbe@396: CREATE VIEW "issue_supporter_in_admission_state" AS
jbe@396:   SELECT DISTINCT
jbe@396:     "issue"."area_id",
jbe@396:     "issue"."id" AS "issue_id",
jbe@396:     "supporter"."member_id",
jbe@396:     "direct_interest_snapshot"."weight"
jbe@396:   FROM "issue"
jbe@396:   JOIN "supporter" ON "supporter"."issue_id" = "issue"."id"
jbe@396:   JOIN "direct_interest_snapshot"
jbe@396:     ON  "direct_interest_snapshot"."issue_id" = "issue"."id"
jbe@396:     AND "direct_interest_snapshot"."event" = "issue"."latest_snapshot_event"
jbe@396:     AND "direct_interest_snapshot"."member_id" = "supporter"."member_id"
jbe@396:   WHERE "issue"."state" = 'admission'::"issue_state";
jbe@396: 
jbe@396: 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';
jbe@396: 
jbe@396: COMMIT;




