# HG changeset patch # User jbe # Date 1296918379 -3600 # Node ID 6bf35cfa3ba8749808f949924120b0ba1ef9ba98 # Parent 0d03c57ebae549f6ae07d8c1463c24552f1ec783 Exceptional updating of "last_login_public" in case of account reactivation diff -r 0d03c57ebae5 -r 6bf35cfa3ba8 core.sql --- a/core.sql Mon Jan 24 17:30:18 2011 +0100 +++ b/core.sql Sat Feb 05 16:06:19 2011 +0100 @@ -2064,7 +2064,16 @@ SELECT * INTO "system_setting_row" FROM "system_setting"; LOCK TABLE "member" IN SHARE ROW EXCLUSIVE MODE; UPDATE "member" SET "last_login_public" = "last_login"::date - WHERE "last_login"::date < 'today'; + FROM ( + SELECT DISTINCT "member"."id" + FROM "member" LEFT JOIN "member_history" + ON "member"."id" = "member_history"."member_id" + WHERE "member"."last_login"::date < 'today' OR ( + "member_history"."until"::date >= 'today' AND + "member_history"."active" = FALSE AND "member"."active" = TRUE + ) + ) AS "subquery" + WHERE "member"."id" = "subquery"."id"; IF "system_setting_row"."member_ttl" NOTNULL THEN UPDATE "member" SET "active" = FALSE WHERE "active" = TRUE @@ -2075,7 +2084,7 @@ END; $$; -COMMENT ON FUNCTION "check_last_login"() IS 'Updates "last_login_public" field, which contains the date but not the time of the last login, and deactivates members who do not login for the time specified in "system_setting"."member_ttl". For privacy reasons this function does not update "last_login_public", if the last login of a member has been today.'; +COMMENT ON FUNCTION "check_last_login"() IS 'Updates "last_login_public" field, which contains the date but not the time of the last login, and deactivates members who do not login for the time specified in "system_setting"."member_ttl". For privacy reasons this function does not update "last_login_public", if the last login of a member has been today (except when member was reactivated today).'; CREATE FUNCTION "calculate_member_counts"()