From f9e674d261fcaae0a0e974dc830b0bb505893c9f Mon Sep 17 00:00:00 2001 From: jsgoldstein Date: Thu, 27 Jul 2023 07:10:49 -1000 Subject: [PATCH] Revert "Add new publicly_searchable attribute to status index (#6)" This reverts commit 4bc96aa6564ffae33e9d10362a6c06c2fa52da14. --- app/chewy/statuses_index.rb | 11 +++++------ app/models/account.rb | 2 -- app/models/concerns/account_statuses_search.rb | 11 ----------- app/models/concerns/status_search.rb | 9 --------- app/models/status.rb | 1 - 5 files changed, 5 insertions(+), 29 deletions(-) delete mode 100644 app/models/concerns/account_statuses_search.rb delete mode 100644 app/models/concerns/status_search.rb diff --git a/app/chewy/statuses_index.rb b/app/chewy/statuses_index.rb index 67284b2c8faf62..6dd4fb18b024dc 100644 --- a/app/chewy/statuses_index.rb +++ b/app/chewy/statuses_index.rb @@ -63,14 +63,13 @@ class StatusesIndex < Chewy::Index end root date_detection: false do - field(:id, type: 'long') - field(:account_id, type: 'long') + field :id, type: 'long' + field :account_id, type: 'long' - field(:text, type: 'text', value: ->(status) { status.searchable_text }) do - field(:stemmed, type: 'text', analyzer: 'content') + field :text, type: 'text', value: ->(status) { status.searchable_text } do + field :stemmed, type: 'text', analyzer: 'content' end - field(:searchable_by, type: 'long', value: ->(status, crutches) { status.searchable_by(crutches) }) - field(:publicly_searchable, type: 'boolean', value: ->(status) { status.publicly_searchable? }) + field :searchable_by, type: 'long', value: ->(status, crutches) { status.searchable_by(crutches) } end end diff --git a/app/models/account.rb b/app/models/account.rb index d801b2073bb547..1edc15972d5eaf 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -79,7 +79,6 @@ class Account < ApplicationRecord include DomainMaterializable include AccountMerging include AccountSearch - include AccountStatusesSearch enum protocol: { ostatus: 0, activitypub: 1 } enum suspension_origin: { local: 0, remote: 1 }, _prefix: true @@ -132,7 +131,6 @@ class Account < ApplicationRecord scope :not_domain_blocked_by_account, ->(account) { where(arel_table[:domain].eq(nil).or(arel_table[:domain].not_in(account.excluded_from_timeline_domains))) } after_update_commit :trigger_update_webhooks - after_update :update_statuses_index!, if: :saved_change_to_discoverable? and Chewy.enabled? delegate :email, :unconfirmed_email, diff --git a/app/models/concerns/account_statuses_search.rb b/app/models/concerns/account_statuses_search.rb deleted file mode 100644 index 99b4a7a3898450..00000000000000 --- a/app/models/concerns/account_statuses_search.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module AccountStatusesSearch - extend ActiveSupport::Concern - - def update_statuses_index! - Chewy.strategy(:sidekiq) do - StatusesIndex.import(query: Status.where(account_id: id)) - end - end -end diff --git a/app/models/concerns/status_search.rb b/app/models/concerns/status_search.rb deleted file mode 100644 index be106d0bcc32e3..00000000000000 --- a/app/models/concerns/status_search.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -module StatusSearch - extend ActiveSupport::Concern - - def publicly_searchable? - public_visibility? && account.discoverable? - end -end diff --git a/app/models/status.rb b/app/models/status.rb index 235c90a449400b..ff85ff2388f88c 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -37,7 +37,6 @@ class Status < ApplicationRecord include StatusSnapshotConcern include RateLimitable include StatusSafeReblogInsert - include StatusSearch rate_limit by: :account, family: :statuses