about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20190807171841_add_known_to_accounts.rb5
-rw-r--r--db/migrate/20190807172051_mark_known_accounts.rb30
-rw-r--r--db/migrate/20190807221924_add_reject_unknown_to_domain_blocks.rb7
-rw-r--r--db/schema.rb4
4 files changed, 45 insertions, 1 deletions
diff --git a/db/migrate/20190807171841_add_known_to_accounts.rb b/db/migrate/20190807171841_add_known_to_accounts.rb
new file mode 100644
index 000000000..ff43f2a32
--- /dev/null
+++ b/db/migrate/20190807171841_add_known_to_accounts.rb
@@ -0,0 +1,5 @@
+class AddKnownToAccounts < ActiveRecord::Migration[5.2]
+  def change
+    add_column :accounts, :known, :boolean, null: false, default: false
+  end
+end
diff --git a/db/migrate/20190807172051_mark_known_accounts.rb b/db/migrate/20190807172051_mark_known_accounts.rb
new file mode 100644
index 000000000..95f9fe99c
--- /dev/null
+++ b/db/migrate/20190807172051_mark_known_accounts.rb
@@ -0,0 +1,30 @@
+class MarkKnownAccounts < ActiveRecord::Migration[5.2]
+  def up
+    Rails.logger.info("Marking known accounts:")
+    known_accounts = local_accounts | packmates | boosted_authors | faved_authors
+    Rails.logger.info("  Updating account flags...")
+    Account.where(id: known_accounts).in_batches.update_all(known: true)
+  end
+
+  private
+
+  def boosted_authors
+    Rails.logger.info("  Gathering boosted accounts...")
+    Status.where(id: Status.local.reblogs.reorder(nil).select(:reblog_of_id)).reorder(nil).pluck(:account_id)
+  end
+
+  def faved_authors
+    Rails.logger.info("  Gathering favourited accounts...")
+    Status.where(id: Favourite.select(:status_id)).reorder(nil).pluck(:account_id)
+  end
+
+  def local_accounts
+    Rails.logger.info("  Gathering local accounts...")
+    Account.local.pluck(:id)
+  end
+
+  def packmates
+    Rails.logger.info("  Gathering packmate accounts...")
+    Account.local.flat_map { |account| account.following_ids | account.follower_ids }
+  end
+end
diff --git a/db/migrate/20190807221924_add_reject_unknown_to_domain_blocks.rb b/db/migrate/20190807221924_add_reject_unknown_to_domain_blocks.rb
new file mode 100644
index 000000000..110d1fb79
--- /dev/null
+++ b/db/migrate/20190807221924_add_reject_unknown_to_domain_blocks.rb
@@ -0,0 +1,7 @@
+class AddRejectUnknownToDomainBlocks < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured {
+      add_column :domain_blocks, :reject_unknown, :boolean, null: false, default: false
+    }
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index a57ac2fd3..7f7d31bd2 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2019_08_06_195913) do
+ActiveRecord::Schema.define(version: 2019_08_07_221924) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -154,6 +154,7 @@ ActiveRecord::Schema.define(version: 2019_08_06_195913) do
     t.boolean "gently", default: false, null: false
     t.boolean "kobold", default: false, null: false
     t.boolean "froze"
+    t.boolean "known", default: false, null: false
     t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
     t.index "lower((username)::text), lower((domain)::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
     t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id"
@@ -274,6 +275,7 @@ ActiveRecord::Schema.define(version: 2019_08_06_195913) do
     t.boolean "reject_reports", default: false, null: false
     t.boolean "force_sensitive", default: false, null: false
     t.text "reason"
+    t.boolean "reject_unknown", default: false, null: false
     t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true
   end