From a93569db53f3c4a4aa1452a43daabc3dc7712109 Mon Sep 17 00:00:00 2001 From: takayamaki Date: Wed, 12 Dec 2018 20:13:34 +0900 Subject: [PATCH] =?UTF-8?q?rake=E3=82=BF=E3=82=B9=E3=82=AF=E3=81=AE?= =?UTF-8?q?=E9=80=B2=E6=8D=97=E3=82=921=E5=80=8B=E3=81=9A=E3=81=A4?= =?UTF-8?q?=E5=87=BA=E3=81=97=E3=81=A6=E3=81=8A=E3=82=8A=E6=99=82=E9=96=93?= =?UTF-8?q?=E3=81=8C=E5=BF=85=E8=A6=81=E4=BB=A5=E4=B8=8A=E3=81=AB=E3=81=8B?= =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=A6=E3=81=97=E3=81=BE=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9F=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/mastodon.rake | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 6bb8d63ac8b33b..98212129ff001f 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -8,18 +8,22 @@ namespace :mastodon do desc 'migrate AccountConversation' task accountConversation: :environment do migrated = 0 - Status.unscoped.local.where(visibility: :direct).includes(:account, mentions: :account).find_each do |status| - AccountConversation.add_status(status.account, status) - migrated += 1 - + Status.unscoped.local.where(visibility: :direct).includes(:account, mentions: :account).find_in_batches do |statuses| + statuses.each do |status| + AccountConversation.add_status(status.account, status) + end + + migrated += statuses.length puts "Migrated #{migrated} rows" end puts - Notification.joins(mention: :status).where(activity_type: 'Mention', statuses: { visibility: :direct }).includes(:account, mention: { status: [:account, mentions: :account] }).find_each do |notification| - AccountConversation.add_status(notification.account, notification.target_status) - migrated += 1 - + Notification.joins(mention: :status).where(activity_type: 'Mention', statuses: { visibility: :direct }).includes(:account, mention: { status: [:account, mentions: :account] }).find_in_batches do |notifications| + notifications.each do |notification| + AccountConversation.add_status(notification.account, notification.target_status) + end + + migrated += notifications.length puts "Migrated #{migrated} rows" end end