Add my reacted statuses search
This commit is contained in:
parent
7b88422644
commit
5fb6bce744
9 changed files with 124 additions and 16 deletions
|
@ -13,6 +13,10 @@
|
|||
#
|
||||
|
||||
class BookmarkCategoryStatus < ApplicationRecord
|
||||
include Paginable
|
||||
|
||||
update_index('statuses', :status) if Chewy.enabled?
|
||||
|
||||
belongs_to :bookmark_category
|
||||
belongs_to :status
|
||||
belongs_to :bookmark
|
||||
|
|
|
@ -13,18 +13,48 @@ module StatusSearchConcern
|
|||
|
||||
ids << account_id if local?
|
||||
|
||||
ids += local_mentioned.pluck(:id)
|
||||
ids += local_favorited.pluck(:id)
|
||||
ids += local_reblogged.pluck(:id)
|
||||
ids += local_bookmarked.pluck(:id)
|
||||
ids += local_emoji_reacted.pluck(:id)
|
||||
ids += local_referenced.pluck(:id)
|
||||
ids += preloadable_poll.local_voters.pluck(:id) if preloadable_poll.present?
|
||||
ids += mentioned_by
|
||||
ids += favourited_by
|
||||
ids += reblogged_by
|
||||
ids += bookmarked_by
|
||||
ids += emoji_reacted_by
|
||||
ids += referenced_by
|
||||
ids += voted_by if preloadable_poll.present?
|
||||
|
||||
ids.uniq
|
||||
end
|
||||
end
|
||||
|
||||
def mentioned_by
|
||||
@mentioned_by ||= local_mentioned.pluck(:id)
|
||||
end
|
||||
|
||||
def favourited_by
|
||||
@favourited_by ||= local_favorited.pluck(:id)
|
||||
end
|
||||
|
||||
def reblogged_by
|
||||
@reblogged_by ||= local_reblogged.pluck(:id)
|
||||
end
|
||||
|
||||
def bookmarked_by
|
||||
@bookmarked_by ||= local_bookmarked.pluck(:id)
|
||||
end
|
||||
|
||||
def emoji_reacted_by
|
||||
@emoji_reacted_by ||= local_emoji_reacted.pluck(:id)
|
||||
end
|
||||
|
||||
def referenced_by
|
||||
@referenced_by ||= local_referenced.pluck(:id)
|
||||
end
|
||||
|
||||
def voted_by
|
||||
return [] if preloadable_poll.blank?
|
||||
|
||||
@voted_by ||= preloadable_poll.local_voters.pluck(:id)
|
||||
end
|
||||
|
||||
def searchable_text
|
||||
[
|
||||
spoiler_text,
|
||||
|
|
|
@ -86,6 +86,7 @@ class Status < ApplicationRecord
|
|||
has_many :referenced_by_statuses, through: :referenced_by_status_objects, class_name: 'Status', source: :status
|
||||
has_many :capability_tokens, class_name: 'StatusCapabilityToken', inverse_of: :status, dependent: :destroy
|
||||
has_many :bookmark_category_relationships, class_name: 'BookmarkCategoryStatus', inverse_of: :status, dependent: :destroy
|
||||
has_many :bookmark_categories, class_name: 'BookmarkCategory', through: :bookmark_category_relationships, source: :bookmark_category
|
||||
has_many :joined_bookmark_categories, class_name: 'BookmarkCategory', through: :bookmark_category_relationships, source: :bookmark_category
|
||||
|
||||
# Those associations are used for the private search index
|
||||
|
@ -93,6 +94,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_bookmark_categoried, -> { merge(Account.local) }, through: :bookmark_categories, source: :account
|
||||
has_many :local_emoji_reacted, -> { merge(Account.local) }, through: :emoji_reactions, source: :account
|
||||
has_many :local_referenced, -> { merge(Account.local) }, through: :referenced_by_statuses, source: :account
|
||||
|
||||
|
@ -435,6 +437,12 @@ class Status < ApplicationRecord
|
|||
compute_searchability
|
||||
end
|
||||
|
||||
def searchable_visibility
|
||||
return limited_scope if limited_visibility? && !none_limited?
|
||||
|
||||
visibility
|
||||
end
|
||||
|
||||
class << self
|
||||
def selectable_visibilities
|
||||
visibilities.keys - %w(direct limited)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue