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 issuemaster
parent
a29f196f95
commit
ad40bf5e0c
@ -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 |
@ -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 |
@ -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 |
Loading…
Reference in new issue