about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-11-16 21:01:07 -0600
committermultiple creatures <dev@multiple-creature.party>2019-11-16 21:01:07 -0600
commit1132af15151713f52d8d1e320271185865a79633 (patch)
treec7d5dd6afb7a60c840a0d3238124f01c747eada8 /lib
parent487c945d160e9349579bf541147c949f8bca3c46 (diff)
Moved to using a normalized text column for searches. Admins using an FTS-enabled version of Monsterfork will need to apply the migration from `dist/search.sql` then run `bundle exec rails monsterfork:index_statuses`.
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/monsterfork.rake17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/tasks/monsterfork.rake b/lib/tasks/monsterfork.rake
new file mode 100644
index 000000000..e55bb1930
--- /dev/null
+++ b/lib/tasks/monsterfork.rake
@@ -0,0 +1,17 @@
+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 statuses #{1+i}-#{statuses.count} of #{total}.")
+      i += statuses.count
+      statuses.each do |s|
+        ActiveRecord::Base.logger.silence { s.update_column(:normalized_text, normalize_status(s)) }
+      end
+    end
+  end
+end