about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-08-09 23:11:50 +0200
committerGitHub <noreply@github.com>2021-08-09 23:11:50 +0200
commit4ac78e2a066508a54de82f1d910ef2fd36c3d106 (patch)
tree350b4b7465ae73a9ad3adb55512586b862f13e9e /db
parent432e3d1eaf816b142959afeda0490641ddcfdf61 (diff)
Add feature to automatically delete old toots (#16529)
* Add account statuses cleanup policy model

* Record last inspected toot to delete to speed up successive calls to statuses_to_delete

* Add service to cleanup a given account's statuses within a budget

* Add worker to go through account policies and delete old toots

* Fix last inspected status id logic

All existing statuses older or equal to last inspected status id must be
kept by the current policy. This is an invariant that must be kept so that
resuming deletion from the last inspected status remains sound.

* Add tests

* Refactor scheduler and add tests

* Add user interface

* Add support for discriminating based on boosts/favs

* Add UI support for min_reblogs and min_favs, rework UI

* Address first round of review comments

* Replace Snowflake#id_at_start with with_random parameter

* Add tests

* Add tests for StatusesCleanupController

* Rework settings page

* Adjust load-avoiding mechanisms

* Please CodeClimate
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb20
-rw-r--r--db/schema.rb18
2 files changed, 38 insertions, 0 deletions
diff --git a/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb b/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb
new file mode 100644
index 000000000..28cfb6ef5
--- /dev/null
+++ b/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb
@@ -0,0 +1,20 @@
+class CreateAccountStatusesCleanupPolicies < ActiveRecord::Migration[6.1]
+  def change
+    create_table :account_statuses_cleanup_policies do |t|
+      t.belongs_to :account, null: false, foreign_key: { on_delete: :cascade }
+      t.boolean :enabled, null: false, default: true
+      t.integer :min_status_age, null: false, default: 2.weeks.seconds
+      t.boolean :keep_direct, null: false, default: true
+      t.boolean :keep_pinned, null: false, default: true
+      t.boolean :keep_polls, null: false, default: false
+      t.boolean :keep_media, null: false, default: false
+      t.boolean :keep_self_fav, null: false, default: true
+      t.boolean :keep_self_bookmark, null: false, default: true
+      t.integer :min_favs, null: true
+      t.integer :min_reblogs, null: true
+
+      t.timestamps
+    end
+  end
+end
+
diff --git a/db/schema.rb b/db/schema.rb
index a0a98eb03..2376afff7 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -114,6 +114,23 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
     t.index ["account_id"], name: "index_account_stats_on_account_id", unique: true
   end
 
+  create_table "account_statuses_cleanup_policies", force: :cascade do |t|
+    t.bigint "account_id", null: false
+    t.boolean "enabled", default: true, null: false
+    t.integer "min_status_age", default: 1209600, null: false
+    t.boolean "keep_direct", default: true, null: false
+    t.boolean "keep_pinned", default: true, null: false
+    t.boolean "keep_polls", default: false, null: false
+    t.boolean "keep_media", default: false, null: false
+    t.boolean "keep_self_fav", default: true, null: false
+    t.boolean "keep_self_bookmark", default: true, null: false
+    t.integer "min_favs"
+    t.integer "min_reblogs"
+    t.datetime "created_at", precision: 6, null: false
+    t.datetime "updated_at", precision: 6, null: false
+    t.index ["account_id"], name: "index_account_statuses_cleanup_policies_on_account_id"
+  end
+
   create_table "account_warning_presets", force: :cascade do |t|
     t.text "text", default: "", null: false
     t.datetime "created_at", null: false
@@ -984,6 +1001,7 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
   add_foreign_key "account_pins", "accounts", column: "target_account_id", on_delete: :cascade
   add_foreign_key "account_pins", "accounts", on_delete: :cascade
   add_foreign_key "account_stats", "accounts", on_delete: :cascade
+  add_foreign_key "account_statuses_cleanup_policies", "accounts", on_delete: :cascade
   add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade
   add_foreign_key "account_warnings", "accounts", on_delete: :nullify
   add_foreign_key "accounts", "accounts", column: "moved_to_account_id", on_delete: :nullify