liquid_feedback_core

changeset 589:aa23fa17604d

Removed "snapshot_retention" configuration: always delete unused snapshots immediately
author jbe
date Fri Dec 07 15:48:02 2018 +0100 (2018-12-07)
parents 6f427a8f8061
children c918d08f5a80
files core.sql lf_update.c
line diff
     1.1 --- a/core.sql	Wed Dec 05 00:35:30 2018 +0100
     1.2 +++ b/core.sql	Fri Dec 07 15:48:02 2018 +0100
     1.3 @@ -67,15 +67,13 @@
     1.4  
     1.5  
     1.6  CREATE TABLE "system_setting" (
     1.7 -        "member_ttl"            INTERVAL,
     1.8 -        "snapshot_retention"    INTERVAL );
     1.9 +        "member_ttl"            INTERVAL );
    1.10  CREATE UNIQUE INDEX "system_setting_singleton_idx" ON "system_setting" ((1));
    1.11  
    1.12  COMMENT ON TABLE "system_setting" IS 'This table contains only one row with different settings in each column.';
    1.13  COMMENT ON INDEX "system_setting_singleton_idx" IS 'This index ensures that "system_setting" only contains one row maximum.';
    1.14  
    1.15  COMMENT ON COLUMN "system_setting"."member_ttl"         IS 'Time after members get their "active" flag set to FALSE, if they do not show any activity.';
    1.16 -COMMENT ON COLUMN "system_setting"."snapshot_retention" IS 'Unreferenced snapshots are retained for the given period of time after creation; set to NULL for infinite retention.';
    1.17  
    1.18  
    1.19  CREATE TABLE "contingent" (
    1.20 @@ -3830,17 +3828,6 @@
    1.21  COMMENT ON VIEW "unused_snapshot" IS 'Snapshots that are not referenced by any issue (either as latest snapshot or as snapshot at phase/state change)';
    1.22  
    1.23  
    1.24 -CREATE VIEW "expired_snapshot" AS
    1.25 -  SELECT "unused_snapshot".* FROM "unused_snapshot" CROSS JOIN "system_setting"
    1.26 -  WHERE "unused_snapshot"."calculated" <
    1.27 -    now() - "system_setting"."snapshot_retention";
    1.28 -
    1.29 -CREATE RULE "delete" AS ON DELETE TO "expired_snapshot" DO INSTEAD
    1.30 -  DELETE FROM "snapshot" WHERE "id" = OLD."id";
    1.31 -
    1.32 -COMMENT ON VIEW "expired_snapshot" IS 'Contains "unused_snapshot"s that are older than "system_setting"."snapshot_retention" (for deletion)';
    1.33 -
    1.34 -
    1.35  CREATE VIEW "open_issue" AS
    1.36    SELECT * FROM "issue" WHERE "closed" ISNULL;
    1.37  
    1.38 @@ -6501,7 +6488,7 @@
    1.39        RAISE WARNING 'Function "check_everything" should only be used for development and debugging purposes';
    1.40        DELETE FROM "expired_session";
    1.41        DELETE FROM "expired_token";
    1.42 -      DELETE FROM "expired_snapshot";
    1.43 +      DELETE FROM "unused_snapshot";
    1.44        PERFORM "check_activity"();
    1.45        PERFORM "calculate_member_counts"();
    1.46        FOR "area_id_v" IN SELECT "id" FROM "area_with_unaccepted_issues" LOOP
    1.47 @@ -6519,6 +6506,7 @@
    1.48            EXIT WHEN "persist_v" ISNULL;
    1.49          END LOOP;
    1.50        END LOOP;
    1.51 +      DELETE FROM "unused_snapshot";
    1.52        RETURN;
    1.53      END;
    1.54    $$;
     2.1 --- a/lf_update.c	Wed Dec 05 00:35:30 2018 +0100
     2.2 +++ b/lf_update.c	Fri Dec 07 15:48:02 2018 +0100
     2.3 @@ -105,8 +105,8 @@
     2.4    // delete expired tokens and authorization codes:
     2.5    exec_sql(db, NULL, &err, 0, "DELETE FROM \"expired_token\"");
     2.6   
     2.7 -  // delete expired snapshots:
     2.8 -  exec_sql(db, NULL, &err, 0, "DELETE FROM \"expired_snapshot\"");
     2.9 +  // delete unused snapshots:
    2.10 +  exec_sql(db, NULL, &err, 0, "DELETE FROM \"unused_snapshot\"");
    2.11   
    2.12    // check member activity:
    2.13    exec_sql(db, NULL, &err, 0, "SET TRANSACTION ISOLATION LEVEL READ COMMITTED; SELECT \"check_activity\"()");
    2.14 @@ -274,7 +274,10 @@
    2.15    }
    2.16    if (res) PQclear(res);
    2.17  
    2.18 -  // cleanup and exit:
    2.19 +  // delete unused snapshots:
    2.20 +  exec_sql(db, NULL, &err, 0, "DELETE FROM \"unused_snapshot\"");
    2.21 +
    2.22 +   // cleanup and exit:
    2.23    PQfinish(db);
    2.24    return err;
    2.25  

Impressum / About Us