diff --git a/app/chewy/statuses_index.rb b/app/chewy/statuses_index.rb index e739ccecb41..50d979e24a1 100644 --- a/app/chewy/statuses_index.rb +++ b/app/chewy/statuses_index.rb @@ -52,7 +52,9 @@ class StatusesIndex < Chewy::Index }, } - index_scope ::Status.unscoped.kept.without_reblogs.includes(:media_attachments, :local_mentioned, :local_favorited, :local_reblogged, :local_bookmarked, :tags, preview_cards_status: :preview_card, preloadable_poll: :local_voters), delete_if: ->(status) { status.searchable_by.empty? } + index_scope ::Status.unscoped.kept.without_reblogs.includes( + :media_attachments, :local_mentioned, :local_favorited, :local_reblogged, :local_bookmarked, :local_replied, :tags, preview_cards_status: :preview_card, preloadable_poll: :local_voters + ), delete_if: ->(status) { status.searchable_by.empty? } root date_detection: false do field(:id, type: 'long') diff --git a/app/lib/importer/statuses_index_importer.rb b/app/lib/importer/statuses_index_importer.rb index 5c8a9f28c8e..baefddee72a 100644 --- a/app/lib/importer/statuses_index_importer.rb +++ b/app/lib/importer/statuses_index_importer.rb @@ -55,6 +55,7 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter local_favourites_scope, local_votes_scope, local_bookmarks_scope, + local_replied_scope, ] end @@ -77,4 +78,8 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter def local_statuses_scope Status.local.select('"statuses"."id", COALESCE("statuses"."reblog_of_id", "statuses"."id") AS status_id') end + + def local_replied_scope + Status.local.where.not(in_reply_to_id: nil).where('in_reply_to_account_id != account_id').select(:id, 'in_reply_to_id AS status_id') + end end diff --git a/app/models/concerns/status/search_concern.rb b/app/models/concerns/status/search_concern.rb index 7f1dbedc451..ffcf9d23066 100644 --- a/app/models/concerns/status/search_concern.rb +++ b/app/models/concerns/status/search_concern.rb @@ -17,6 +17,7 @@ module Status::SearchConcern ids += local_favorited.pluck(:id) ids += local_reblogged.pluck(:id) ids += local_bookmarked.pluck(:id) + ids += local_replied.pluck(:id) ids += preloadable_poll.local_voters.pluck(:id) if preloadable_poll.present? ids.uniq diff --git a/app/models/status.rb b/app/models/status.rb index 0bff4f2825d..7e52fa008c5 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -90,6 +90,7 @@ class Status < ApplicationRecord has_many :local_favorited, -> { merge(Account.local) }, through: :favourites, source: :account has_many :local_reblogged, -> { merge(Account.local) }, through: :reblogs, source: :account has_many :local_bookmarked, -> { merge(Account.local) }, through: :bookmarks, source: :account + has_many :local_replied, -> { merge(Account.local) }, through: :replies, source: :account has_and_belongs_to_many :tags # rubocop:disable Rails/HasAndBelongsToMany