]> cat aescling's git repositories - mastodon.git/commitdiff
Let votes statuses are also searchable (#18070)
authorJeong Arm <kjwonmail@gmail.com>
Sat, 23 Apr 2022 19:47:27 +0000 (04:47 +0900)
committersingle-right-quote <11325618-aescling@users.noreply.gitlab.com>
Thu, 5 May 2022 03:56:00 +0000 (23:56 -0400)
app/chewy/statuses_index.rb
app/models/status.rb

index 1381a96ed449081470c88570e8cceac7c4bdbf5f..1304aeedbdd36b097a190033b1df79caa8e8bc8e 100644 (file)
@@ -55,6 +55,11 @@ class StatusesIndex < Chewy::Index
     data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
   end
 
+  crutch :votes do |collection|
+    data = ::PollVote.joins(:poll).where(poll: { status_id: collection.map(&:id) }).where(account: Account.local).pluck(:status_id, :account_id)
+    data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
+  end
+
   root date_detection: false do
     field :id, type: 'long'
     field :account_id, type: 'long'
index 9eaf856685c7cbb7f3ae0645a1f85c84684d058c..cc7ee568f9e886ef2f69b6c613047b8740407a75 100644 (file)
@@ -150,11 +150,13 @@ class Status < ApplicationRecord
       ids += favourites.where(account: Account.local).pluck(:account_id)
       ids += reblogs.where(account: Account.local).pluck(:account_id)
       ids += bookmarks.where(account: Account.local).pluck(:account_id)
+      ids += poll.votes.where(account: Account.local).pluck(:account_id) if poll.present?
     else
       ids += preloaded.mentions[id] || []
       ids += preloaded.favourites[id] || []
       ids += preloaded.reblogs[id] || []
       ids += preloaded.bookmarks[id] || []
+      ids += preloaded.votes[id] || []
     end
 
     ids.uniq