about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-06-02 16:08:31 -0500
committerDavid Yip <yipdw@member.fsf.org>2018-06-02 16:08:31 -0500
commita641d1b5b8e9f20104ab16e5419e6dee4e5af37f (patch)
tree30eeb0f208b0ff314d71f2f90935fc3ab5fc282f /lib
parent9ad5de8a3a5a14760f83f3d0f95eddca1fc4b106 (diff)
parent165b5dc7f5711efd07adb73316e94d89b9e7e3a3 (diff)
Merge remote-tracking branch 'personal/merge/tootsuite/master' into gs-master
Diffstat (limited to 'lib')
-rw-r--r--lib/mastodon/version.rb4
-rw-r--r--lib/tasks/mastodon.rake25
2 files changed, 11 insertions, 18 deletions
diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb
index 9a7d49674..622103ea4 100644
--- a/lib/mastodon/version.rb
+++ b/lib/mastodon/version.rb
@@ -13,7 +13,7 @@ module Mastodon
     end
 
     def patch
-      0
+      1
     end
 
     def pre
@@ -21,7 +21,7 @@ module Mastodon
     end
 
     def flags
-      ''
+      'rc1'
     end
 
     def to_a
diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake
index 00a85fa5e..8ff29ea9e 100644
--- a/lib/tasks/mastodon.rake
+++ b/lib/tasks/mastodon.rake
@@ -502,18 +502,17 @@ namespace :mastodon do
 
     desc 'Remove media attachments attributed to silenced accounts'
     task remove_silenced: :environment do
-      MediaAttachment.where(account: Account.silenced).find_each(&:destroy)
+      MediaAttachment.where(account: Account.silenced).select(:id).find_in_batches do |media_attachments|
+        Maintenance::DestroyMediaWorker.push_bulk(media_attachments.map(&:id))
+      end
     end
 
     desc 'Remove cached remote media attachments that are older than NUM_DAYS. By default 7 (week)'
     task remove_remote: :environment do
       time_ago = ENV.fetch('NUM_DAYS') { 7 }.to_i.days.ago
 
-      MediaAttachment.where.not(remote_url: '').where.not(file_file_name: nil).where('created_at < ?', time_ago).find_each do |media|
-        next unless media.file.exists?
-
-        media.file.destroy
-        media.save
+      MediaAttachment.where.not(remote_url: '').where.not(file_file_name: nil).where('created_at < ?', time_ago).select(:id).find_in_batches do |media_attachments|
+        Maintenance::UncacheMediaWorker.push_bulk(media_attachments.map(&:id))
       end
     end
 
@@ -529,14 +528,8 @@ namespace :mastodon do
       accounts = Account.remote
       accounts = accounts.where(domain: ENV['DOMAIN']) if ENV['DOMAIN'].present?
 
-      accounts.find_each do |account|
-        begin
-          account.reset_avatar!
-          account.reset_header!
-          account.save
-        rescue Paperclip::Error
-          puts "Error resetting avatar and header for account #{username}@#{domain}"
-        end
+      accounts.select(:id).find_in_batches do |accounts_batch|
+        Maintenance::RedownloadAccountMediaWorker.push_bulk(accounts_batch.map(&:id))
       end
     end
   end
@@ -568,8 +561,8 @@ namespace :mastodon do
 
     desc 'Generates home timelines for users who logged in in the past two weeks'
     task build: :environment do
-      User.active.includes(:account).find_each do |u|
-        PrecomputeFeedService.new.call(u.account)
+      User.active.select(:account_id).find_in_batches do |users|
+        RegenerationWorker.push_bulk(users.map(&:account_id))
       end
     end
   end