diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-05-30 21:09:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-30 21:09:30 +0200 |
commit | ad40bf5e0c77baacbeda248ccca8d310e786ff61 (patch) | |
tree | f11c39df5e63a3a6e13722a88a92f1e024e60625 /app/workers | |
parent | a29f196f95ce335eb8d4cb5aa22ba1f06a52ce01 (diff) |
Speed up some rake tasks by moving execution to Sidekiq (#7678)
* Speed up some rake tasks by moving execution to Sidekiq mastodon:media:remove_silenced mastodon:media:remove_remote mastodon:media:redownload_avatars mastodon:feeds:build * Fix code style issue
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/maintenance/destroy_media_worker.rb | 14 | ||||
-rw-r--r-- | app/workers/maintenance/redownload_account_media_worker.rb | 16 | ||||
-rw-r--r-- | app/workers/maintenance/uncache_media_worker.rb | 18 |
3 files changed, 48 insertions, 0 deletions
diff --git a/app/workers/maintenance/destroy_media_worker.rb b/app/workers/maintenance/destroy_media_worker.rb new file mode 100644 index 000000000..5f052983b --- /dev/null +++ b/app/workers/maintenance/destroy_media_worker.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class Maintenance::DestroyMediaWorker + include Sidekiq::Worker + + sidekiq_options queue: 'pull' + + def perform(media_attachment_id) + media = MediaAttachment.find(media_attachment_id) + media.destroy + rescue ActiveRecord::RecordNotFound + true + end +end diff --git a/app/workers/maintenance/redownload_account_media_worker.rb b/app/workers/maintenance/redownload_account_media_worker.rb new file mode 100644 index 000000000..fc26815f2 --- /dev/null +++ b/app/workers/maintenance/redownload_account_media_worker.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class Maintenance::RedownloadAccountMediaWorker + include Sidekiq::Worker + + sidekiq_options queue: 'pull', retry: false + + def perform(account_id) + account = Account.find(account_id) + account.reset_avatar! + account.reset_header! + account.save + rescue ActiveRecord::RecordNotFound + true + end +end diff --git a/app/workers/maintenance/uncache_media_worker.rb b/app/workers/maintenance/uncache_media_worker.rb new file mode 100644 index 000000000..f6a51a1b8 --- /dev/null +++ b/app/workers/maintenance/uncache_media_worker.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class Maintenance::UncacheMediaWorker + include Sidekiq::Worker + + sidekiq_options queue: 'pull' + + def perform(media_attachment_id) + media = MediaAttachment.find(media_attachment_id) + + return unless media.file.exists? + + media.file.destroy + media.save + rescue ActiveRecord::RecordNotFound + true + end +end |