liquid_feedback_core
diff update/core-update.v1.3.0-v1.3.1.sql @ 103:bc8aa59b0945
Introduced "last_login_public" field, which is only updated after each day and does only contain date but not time for privacy reasons
(required changes in lf_update)
(required changes in lf_update)
author | jbe |
---|---|
date | Sat Jan 22 20:09:18 2011 +0100 (2011-01-22) |
parents | 2daa8ce3d743 |
children | 0d03c57ebae5 |
line diff
1.1 --- a/update/core-update.v1.3.0-v1.3.1.sql Tue Jan 04 02:55:01 2011 +0100 1.2 +++ b/update/core-update.v1.3.0-v1.3.1.sql Sat Jan 22 20:09:18 2011 +0100 1.3 @@ -4,10 +4,26 @@ 1.4 SELECT * FROM (VALUES ('1.3.1', 1, 3, 1)) 1.5 AS "subquery"("string", "major", "minor", "revision"); 1.6 1.7 +ALTER TABLE "member" ADD COLUMN "last_login_public" DATE; 1.8 ALTER TABLE "member" ADD COLUMN "locked" BOOLEAN NOT NULL DEFAULT FALSE; 1.9 1.10 -COMMENT ON COLUMN "member"."locked" IS 'Locked members can not log in.'; 1.11 -COMMENT ON COLUMN "member"."active" IS 'Memberships, support and votes are taken into account when corresponding members are marked as active. When the user does not log in for an extended period of time, this flag may be set to FALSE. If the user is not locked, he/she may reset the active flag by logging in.'; 1.12 +COMMENT ON COLUMN "member"."last_login" IS 'Timestamp of last login'; 1.13 +COMMENT ON COLUMN "member"."last_login_public" IS 'Date of last login (time stripped for privacy reasons, updated only after day change)'; 1.14 +COMMENT ON COLUMN "member"."locked" IS 'Locked members can not log in.'; 1.15 +COMMENT ON COLUMN "member"."active" IS 'Memberships, support and votes are taken into account when corresponding members are marked as active. When the user does not log in for an extended period of time, this flag may be set to FALSE. If the user is not locked, he/she may reset the active flag by logging in.'; 1.16 + 1.17 +CREATE FUNCTION "publish_last_login"() 1.18 + RETURNS VOID 1.19 + LANGUAGE 'plpgsql' VOLATILE AS $$ 1.20 + BEGIN 1.21 + LOCK TABLE "member" IN SHARE ROW EXCLUSIVE MODE; 1.22 + UPDATE "member" SET "last_login_public" = "last_login"::date 1.23 + WHERE "last_login"::date < 'today'; 1.24 + RETURN; 1.25 + END; 1.26 + $$; 1.27 + 1.28 +COMMENT ON FUNCTION "publish_last_login"() IS 'Updates "last_login_public" field, which contains the date but not the time of the last login. For privacy reasons this function does not update "last_login_public", if the last login of a member has been today.'; 1.29 1.30 CREATE OR REPLACE FUNCTION "create_interest_snapshot" 1.31 ( "issue_id_p" "issue"."id"%TYPE ) 1.32 @@ -80,4 +96,79 @@ 1.33 END; 1.34 $$; 1.35 1.36 +CREATE OR REPLACE FUNCTION "check_everything"() 1.37 + RETURNS VOID 1.38 + LANGUAGE 'plpgsql' VOLATILE AS $$ 1.39 + DECLARE 1.40 + "issue_id_v" "issue"."id"%TYPE; 1.41 + BEGIN 1.42 + DELETE FROM "expired_session"; 1.43 + PERFORM "publish_last_login"(); 1.44 + PERFORM "calculate_member_counts"(); 1.45 + FOR "issue_id_v" IN SELECT "id" FROM "open_issue" LOOP 1.46 + PERFORM "check_issue"("issue_id_v"); 1.47 + END LOOP; 1.48 + FOR "issue_id_v" IN SELECT "id" FROM "issue_with_ranks_missing" LOOP 1.49 + PERFORM "calculate_ranks"("issue_id_v"); 1.50 + END LOOP; 1.51 + RETURN; 1.52 + END; 1.53 + $$; 1.54 + 1.55 +COMMENT ON FUNCTION "check_everything"() IS 'Amongst other regular tasks this function performs "check_issue" for every open issue, and if possible, automatically calculates ranks. Use this function only for development and debugging purposes, as long transactions with exclusive locking may result. In productive environments you should call the lf_update program instead.'; 1.56 + 1.57 +CREATE OR REPLACE FUNCTION "delete_member"("member_id_p" "member"."id"%TYPE) 1.58 + RETURNS VOID 1.59 + LANGUAGE 'plpgsql' VOLATILE AS $$ 1.60 + BEGIN 1.61 + UPDATE "member" SET 1.62 + "last_login" = NULL, 1.63 + "last_login_public" = NULL, 1.64 + "login" = NULL, 1.65 + "password" = NULL, 1.66 + "locked" = TRUE, 1.67 + "active" = FALSE, 1.68 + "notify_email" = NULL, 1.69 + "notify_email_unconfirmed" = NULL, 1.70 + "notify_email_secret" = NULL, 1.71 + "notify_email_secret_expiry" = NULL, 1.72 + "notify_email_lock_expiry" = NULL, 1.73 + "password_reset_secret" = NULL, 1.74 + "password_reset_secret_expiry" = NULL, 1.75 + "organizational_unit" = NULL, 1.76 + "internal_posts" = NULL, 1.77 + "realname" = NULL, 1.78 + "birthday" = NULL, 1.79 + "address" = NULL, 1.80 + "email" = NULL, 1.81 + "xmpp_address" = NULL, 1.82 + "website" = NULL, 1.83 + "phone" = NULL, 1.84 + "mobile_phone" = NULL, 1.85 + "profession" = NULL, 1.86 + "external_memberships" = NULL, 1.87 + "external_posts" = NULL, 1.88 + "statement" = NULL 1.89 + WHERE "id" = "member_id_p"; 1.90 + -- "text_search_data" is updated by triggers 1.91 + DELETE FROM "setting" WHERE "member_id" = "member_id_p"; 1.92 + DELETE FROM "setting_map" WHERE "member_id" = "member_id_p"; 1.93 + DELETE FROM "member_relation_setting" WHERE "member_id" = "member_id_p"; 1.94 + DELETE FROM "member_image" WHERE "member_id" = "member_id_p"; 1.95 + DELETE FROM "contact" WHERE "member_id" = "member_id_p"; 1.96 + DELETE FROM "area_setting" WHERE "member_id" = "member_id_p"; 1.97 + DELETE FROM "issue_setting" WHERE "member_id" = "member_id_p"; 1.98 + DELETE FROM "initiative_setting" WHERE "member_id" = "member_id_p"; 1.99 + DELETE FROM "suggestion_setting" WHERE "member_id" = "member_id_p"; 1.100 + DELETE FROM "membership" WHERE "member_id" = "member_id_p"; 1.101 + DELETE FROM "ignored_issue" WHERE "member_id" = "member_id_p"; 1.102 + DELETE FROM "delegation" WHERE "truster_id" = "member_id_p"; 1.103 + DELETE FROM "direct_voter" USING "issue" 1.104 + WHERE "direct_voter"."issue_id" = "issue"."id" 1.105 + AND "issue"."closed" ISNULL 1.106 + AND "member_id" = "member_id_p"; 1.107 + RETURN; 1.108 + END; 1.109 + $$; 1.110 + 1.111 COMMIT;