about summary refs log tree commit diff
path: root/lib/tasks
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>2017-12-07 11:37:43 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-12-07 03:37:43 +0100
commitc083816c2479dcdfa6674c47a75a8293bf64a947 (patch)
treedddc1ffa56dae8a8856ec9c80af049beb5e66046 /lib/tasks
parent432761f37574b4e4159283f595e6c094b7bde449 (diff)
Add embed_url to preview cards (#5775)
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/mastodon.rake12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake
index 995cf0d6f..0f2cc536a 100644
--- a/lib/tasks/mastodon.rake
+++ b/lib/tasks/mastodon.rake
@@ -326,5 +326,17 @@ namespace :mastodon do
         end
       end
     end
+
+    desc 'Migrate photo preview cards made before 2.1'
+    task migrate_photo_preview_cards: :environment do
+      status_ids = Status.joins(:preview_cards)
+                         .where(preview_cards: { embed_url: '', type: :photo })
+                         .reorder(nil)
+                         .group(:id)
+                         .pluck(:id)
+
+      PreviewCard.where(embed_url: '', type: :photo).delete_all
+      LinkCrawlWorker.push_bulk status_ids
+    end
   end
 end