Don't use Current.account for search records

It doesn't actually work, and even if we could make it work reliably
we are better off if the records always know to go to the right shard.

It does make the interface a bit more complicated as we need to select
the right shard class with `for(account_id)`.
This commit is contained in:
Donal McBreen
2025-11-25 11:34:41 +00:00
parent 4c4f6957ec
commit b571303385
10 changed files with 63 additions and 66 deletions
+2 -8
View File
@@ -12,16 +12,10 @@ namespace :search do
end
puts "Reindexing cards..."
Card.find_each do |card|
Current.account = card.account
card.reindex
end
Card.includes(:rich_text_description).find_each(&:reindex)
puts "Reindexing comments..."
Comment.find_each do |comment|
Current.account = comment.account
comment.reindex
end
Comment.includes(:rich_text_body, :card).find_each(&:reindex)
puts "Done! Reindexed #{Card.count} cards and #{Comment.count} comments."
end