liquid_feedback_core

changeset 472:0fa0d2daa54a

Removed experimental algorithm for determining issues to be included in notification mails
author jbe
date Mon Mar 28 14:41:28 2016 +0200 (2016-03-28)
parents 124b9e7c3c23
children 234c9760589d
files core.sql
line diff
     1.1 --- a/core.sql	Sun Mar 27 01:18:07 2016 +0100
     1.2 +++ b/core.sql	Mon Mar 28 14:41:28 2016 +0200
     1.3 @@ -1276,27 +1276,6 @@
     1.4  COMMENT ON INDEX "notification_sent_singleton_idx" IS 'This index ensures that "notification_sent" only contains one row maximum.';
     1.5  
     1.6  
     1.7 -CREATE TABLE "advertised_initiative" (
     1.8 -        PRIMARY KEY ("member_id", "initiative_id", "time_serial"),
     1.9 -        "member_id"             INT4            NOT NULL REFERENCES "member" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
    1.10 -        "initiative_id"         INT4            NOT NULL REFERENCES "initiative" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
    1.11 -        "time_serial"           SERIAL8 );
    1.12 -CREATE INDEX "advertised_initiative_initiative_id_idx" ON "advertised_initiative" ("initiative_id");
    1.13 -
    1.14 -COMMENT ON TABLE "advertised_initiative" IS 'Stores which initiatives have been advertised to a member in a mail digest';
    1.15 -
    1.16 -COMMENT ON COLUMN "advertised_initiative"."time_serial" IS 'An increasing integer that may be used to determine which issue or initiative was advertised the longest ago (may be equal or consecutive for those initiatives that are sent in the same notification)';
    1.17 -
    1.18 -
    1.19 -CREATE TABLE "advertised_suggestion" (
    1.20 -        PRIMARY KEY ("member_id", "suggestion_id"),
    1.21 -        "member_id"             INT4            NOT NULL REFERENCES "member" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
    1.22 -        "suggestion_id"         INT4            NOT NULL REFERENCES "suggestion" ("id") ON DELETE CASCADE ON UPDATE CASCADE );
    1.23 -CREATE INDEX "advertised_suggestion_suggestion_id_idx" ON "advertised_suggestion" ("suggestion_id");
    1.24 -
    1.25 -COMMENT ON TABLE "advertised_initiative" IS 'Stores which suggestions have been advertised to a member in a mail digest';
    1.26 -
    1.27 -
    1.28  
    1.29  ----------------------------------------------
    1.30  -- Writing of history entries and event log --
    1.31 @@ -2401,127 +2380,6 @@
    1.32  COMMENT ON VIEW "event_seen_by_member" IS 'Events as seen by a member, depending on its memberships, interests and support, but ignoring members "notify_level"';
    1.33  
    1.34  
    1.35 -CREATE VIEW "relevant_issue_for_notification" AS
    1.36 -  SELECT
    1.37 -    "member"."id" AS "member_id",
    1.38 -    "issue"."id" AS "issue_id"
    1.39 -  FROM "member" CROSS JOIN "issue"
    1.40 -  JOIN "area" ON "area"."id" = "issue"."area_id"
    1.41 -  LEFT JOIN "privilege"
    1.42 -    ON "privilege"."member_id" = "member"."id"
    1.43 -    AND "privilege"."unit_id" = "area"."unit_id"
    1.44 -  LEFT JOIN "subscription"
    1.45 -    ON "subscription"."member_id" = "member"."id"
    1.46 -    AND "subscription"."unit_id" = "area"."unit_id"
    1.47 -  LEFT JOIN "interest"
    1.48 -    ON "interest"."member_id" = "member"."id"
    1.49 -    AND "interest"."issue_id" = "issue"."id"
    1.50 -  LEFT JOIN "ignored_area"
    1.51 -    ON "ignored_area"."member_id" = "member"."id"
    1.52 -    AND "ignored_area"."area_id" = "issue"."area_id"
    1.53 -  WHERE
    1.54 -    ( "privilege"."initiative_right" OR "privilege"."voting_right" OR
    1.55 -      "subscription"."member_id" NOTNULL ) AND
    1.56 -    ( ( "issue"."state" IN ('admission', 'discussion', 'verification') AND
    1.57 -        "interest"."member_id" NOTNULL ) OR
    1.58 -      ( "issue"."state" IN ('discussion', 'verification') AND
    1.59 -        "ignored_area"."member_id" ISNULL ) );
    1.60 -
    1.61 -COMMENT ON VIEW "relevant_issue_for_notification" IS 'Helper view for "issue_for_notification" containing issues which are relevant to the member';
    1.62 -
    1.63 -
    1.64 -CREATE VIEW "new_issue_for_notification" AS
    1.65 -  SELECT DISTINCT ON ("member_id", "area_id")
    1.66 -    "member"."id"     AS "member_id",
    1.67 -    "issue"."area_id" AS "area_id",
    1.68 -    "issue"."id"      AS "issue_id"
    1.69 -  FROM "member" CROSS JOIN "issue"
    1.70 -  JOIN "area" ON "area"."id" = "issue"."area_id"
    1.71 -  LEFT JOIN "privilege"
    1.72 -    ON "privilege"."member_id" = "member"."id"
    1.73 -    AND "privilege"."unit_id" = "area"."unit_id"
    1.74 -  LEFT JOIN "subscription"
    1.75 -    ON "subscription"."member_id" = "member"."id"
    1.76 -    AND "subscription"."unit_id" = "area"."unit_id"
    1.77 -  LEFT JOIN "interest"
    1.78 -    ON "interest"."member_id" = "member"."id"
    1.79 -    AND "interest"."issue_id" = "issue"."id"
    1.80 -  LEFT JOIN "ignored_area"
    1.81 -    ON "ignored_area"."member_id" = "member"."id"
    1.82 -    AND "ignored_area"."area_id" = "issue"."area_id"
    1.83 -  LEFT JOIN
    1.84 -    ( "advertised_initiative" JOIN "initiative"
    1.85 -      ON "advertised_initiative"."initiative_id" = "initiative"."id" )
    1.86 -    ON "advertised_initiative"."member_id" = "member"."id"
    1.87 -    AND "initiative"."issue_id" = "issue"."id"
    1.88 -  JOIN "issue_order_in_admission_state"
    1.89 -    ON "issue_order_in_admission_state"."id" = "issue"."id"
    1.90 -  WHERE
    1.91 -    ( "privilege"."initiative_right" OR "privilege"."voting_right" OR
    1.92 -      "subscription"."member_id" NOTNULL ) AND
    1.93 -    "issue"."state" IN ('admission') AND
    1.94 -    "interest"."member_id" ISNULL AND
    1.95 -    "advertised_initiative"."member_id" ISNULL
    1.96 -  ORDER BY
    1.97 -    "member_id",
    1.98 -    "area_id",
    1.99 -    "issue_order_in_admission_state"."order_in_area";
   1.100 -
   1.101 -COMMENT ON VIEW "new_issue_for_notification" IS 'Helper view for "issue_for_notification" containing one not-yet-advertised issue per "area" which is in ''admission'' phase and has the best proportional ranking';
   1.102 -
   1.103 -
   1.104 -CREATE VIEW "new_updated_issue_for_notification" AS
   1.105 -  SELECT DISTINCT ON ("member_id", "area_id") * FROM (
   1.106 -    SELECT DISTINCT ON ("member_id", "area_id", "issue_id")
   1.107 -      "member"."id"                         AS "member_id",
   1.108 -      "issue"."area_id"                     AS "area_id",
   1.109 -      "issue"."id"                          AS "issue_id",
   1.110 -      "advertised_initiative"."time_serial" AS "time_serial"
   1.111 -    FROM "member" CROSS JOIN "issue"
   1.112 -    JOIN "area" ON "area"."id" = "issue"."area_id"
   1.113 -    LEFT JOIN "privilege"
   1.114 -      ON "privilege"."member_id" = "member"."id"
   1.115 -      AND "privilege"."unit_id" = "area"."unit_id"
   1.116 -    LEFT JOIN "subscription"
   1.117 -      ON "subscription"."member_id" = "member"."id"
   1.118 -      AND "subscription"."unit_id" = "area"."unit_id"
   1.119 -    LEFT JOIN "interest"
   1.120 -      ON "interest"."member_id" = "member"."id"
   1.121 -      AND "interest"."issue_id" = "issue"."id"
   1.122 -    LEFT JOIN "ignored_area"
   1.123 -      ON "ignored_area"."member_id" = "member"."id"
   1.124 -      AND "ignored_area"."area_id" = "issue"."area_id"
   1.125 -    JOIN
   1.126 -      ( "advertised_initiative" JOIN "initiative"
   1.127 -        ON "advertised_initiative"."initiative_id" = "initiative"."id" )
   1.128 -      ON "advertised_initiative"."member_id" = "member"."id"
   1.129 -      AND "initiative"."issue_id" = "issue"."id"
   1.130 -    WHERE
   1.131 -      ( "privilege"."initiative_right" OR "privilege"."voting_right" OR
   1.132 -        "subscription"."member_id" NOTNULL ) AND
   1.133 -      "issue"."state" IN ('admission') AND
   1.134 -      "interest"."member_id" ISNULL AND
   1.135 -    ORDER BY
   1.136 -      "member_id",
   1.137 -      "area_id",
   1.138 -      "issue_id",
   1.139 -      "time_serial" DESC
   1.140 -  ) AS "subquery"
   1.141 -  ORDER BY "member_id", "area_id", "time_serial" ASC;  -- TODO: require new initiatives or new initiative draft since last digest
   1.142 -
   1.143 -COMMENT ON VIEW "new_updated_issue_for_notification" IS 'Helper view for "issue_for_notification" containing one previously advertised issue per "area" which is in ''admission'' phase and has new or updated initiatives for the recipient';
   1.144 -
   1.145 -
   1.146 -CREATE VIEW "issue_for_notification" AS
   1.147 -  SELECT "member_id", "issue_id" FROM "relevant_issue_for_notification"
   1.148 -  UNION
   1.149 -  SELECT "member_id", "issue_id" FROM "new_issue_for_notification"
   1.150 -  UNION
   1.151 -  SELECT "member_id", "issue_id" FROM "new_updated_issue_for_notification";
   1.152 -
   1.153 -COMMENT ON VIEW "issue_for_notification" IS 'Issues that are considered in notifications sent to the member';
   1.154 -
   1.155 -
   1.156  
   1.157  ------------------------------------------------------
   1.158  -- Row set returning function for delegation chains --

Impressum / About Us