blob: efc45b2feef3a73d20550ea8b7ceb11a6f3bd4ea (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
namespace :monsterfork do
desc '(Re-)Index statuses for search.'
task index_statuses: :environment do
include TextHelper
i = 0
total = Status.count
Status.find_in_batches do |statuses|
ActiveRecord::Base.logger.info("Indexing status #{1+i} of #{total}.")
ActiveRecord::Base.logger.silence do
i += statuses.count
statuses.each do |s|
begin
next if s.destroyed?
s.update_column(:normalized_text, normalize_status(s))
rescue ActiveRecord::RecordNotFound
true
end
end
end
end
end
end
|