Compare commits

...

6 Commits

Author SHA1 Message Date
Jeong Arm
3b7099bcdf
Merge 7a21ff2088 into c442589593 2025-07-10 08:04:32 +00:00
Claire
7a21ff2088
Merge branch 'main' into search-replied-to 2024-11-22 10:14:50 +01:00
Jeong Arm
823ed7ad15 Fix ruby lint 2024-05-27 22:41:33 +09:00
Jeong Arm
8d7ba830f5 Remove get_status_ids
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
2024-05-27 22:36:21 +09:00
Jeong Arm
dded2f01b3 Fix N+1 and chewy importer 2024-05-27 22:36:19 +09:00
Jeong Arm
e0e58ab9cf Make statuses that local user replied to also searchable 2024-05-27 22:35:27 +09:00
4 changed files with 10 additions and 1 deletions

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -93,6 +93,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