about summary refs log tree commit diff
path: root/lib/tasks/mastodon.rake
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2017-12-06 22:34:42 -0600
committerDavid Yip <yipdw@member.fsf.org>2017-12-06 22:34:42 -0600
commitddb61deccefeda2346e64002528764841bcb7315 (patch)
tree0ee86119b8260661d85e5e41a1342c30802f620b /lib/tasks/mastodon.rake
parent935c1944e27be4df9ba821a0f38fd599d1877a31 (diff)
parent744447b3c04d7806e383f0d1ad7a10c73bd667ef (diff)
Merge remote-tracking branch 'personal/merge/tootsuite/master' into gs-master
Diffstat (limited to 'lib/tasks/mastodon.rake')
-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