Change tootctl to use inline parallelization instead of Sidekiq (#11776)
- Remove --background option - Add --concurrency(=5) option - Add progress bars
This commit is contained in:
parent
9045f5e3f8
commit
8674814825
15 changed files with 200 additions and 337 deletions
|
@ -129,6 +129,7 @@ class MediaAttachment < ApplicationRecord
|
|||
scope :unattached, -> { where(status_id: nil, scheduled_status_id: nil) }
|
||||
scope :local, -> { where(remote_url: '') }
|
||||
scope :remote, -> { where.not(remote_url: '') }
|
||||
scope :cached, -> { remote.where.not(file_file_name: nil) }
|
||||
|
||||
default_scope { order(id: :asc) }
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ class PreviewCard < ApplicationRecord
|
|||
validates_attachment_size :image, less_than: LIMIT
|
||||
remotable_attachment :image, LIMIT
|
||||
|
||||
scope :cached, -> { where.not(image_file_name: [nil, '']) }
|
||||
|
||||
before_save :extract_dimensions, if: :link?
|
||||
|
||||
def save_with_optional_image!
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Maintenance::DestroyMediaWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: 'pull'
|
||||
|
||||
def perform(media_attachment_id)
|
||||
media = media_attachment_id.is_a?(MediaAttachment) ? media_attachment_id : MediaAttachment.find(media_attachment_id)
|
||||
media.destroy
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
true
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Maintenance::RedownloadAccountMediaWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: 'pull', retry: false
|
||||
|
||||
def perform(account_id)
|
||||
account = account_id.is_a?(Account) ? account_id : Account.find(account_id)
|
||||
account.reset_avatar!
|
||||
account.reset_header!
|
||||
account.save
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
true
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Maintenance::UncacheMediaWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: 'pull'
|
||||
|
||||
def perform(media_attachment_id)
|
||||
media = media_attachment_id.is_a?(MediaAttachment) ? media_attachment_id : MediaAttachment.find(media_attachment_id)
|
||||
|
||||
return if media.file.blank?
|
||||
|
||||
media.file.destroy
|
||||
media.save
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
true
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Maintenance::UncachePreviewWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: 'pull'
|
||||
|
||||
def perform(preview_card_id)
|
||||
preview_card = PreviewCard.find(preview_card_id)
|
||||
|
||||
return if preview_card.image.blank?
|
||||
|
||||
preview_card.image.destroy
|
||||
preview_card.save
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
true
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue