Skip to content
This repository has been archived by the owner on May 16, 2019. It is now read-only.

Commit

Permalink
rakeタスクの進捗を1個ずつ出しており時間が必要以上にかかってしまっていた問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
takayamaki committed Dec 12, 2018
1 parent 13d19af commit a93569d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/tasks/mastodon.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a93569d

Please sign in to comment.