mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-26 16:53:12 +08:00
Generate all preview for assets at same time
This commit is contained in:
parent
e68b8f55c2
commit
9d59d56818
2 changed files with 9 additions and 5 deletions
|
@ -30,7 +30,7 @@ module ActiveStorage
|
|||
return true if preview_exists
|
||||
|
||||
unless processing
|
||||
ActiveStorage::PreviewJob.perform_later(@blob.id, params[:variation_key])
|
||||
ActiveStorage::PreviewJob.perform_later(@blob.id)
|
||||
@blob.attachments.take.record.update(file_processing: true)
|
||||
end
|
||||
|
||||
|
|
|
@ -14,12 +14,16 @@ class ActiveStorage::PreviewJob < ActiveStorage::BaseJob
|
|||
|
||||
retry_on ActiveStorage::IntegrityError, attempts: 3, wait: :exponentially_longer
|
||||
|
||||
def perform(blob_id, variation_key)
|
||||
def perform(blob_id)
|
||||
blob = ActiveStorage::Blob.find(blob_id)
|
||||
preview = blob.representation(variation_key).processed
|
||||
blob.attachments.take.record.update(file_processing: false)
|
||||
|
||||
preview = blob.representation(resize_to_limit: Constants::MEDIUM_PIC_FORMAT).processed
|
||||
Rails.logger.info "Preview for the Blod with id: #{blob.id} - successfully generated.\n" \
|
||||
"Transformations applied: #{preview.variation.transformations}"
|
||||
|
||||
preview = blob.representation(resize_to_limit: Constants::LARGE_PIC_FORMAT).processed
|
||||
Rails.logger.info "Preview for the Blod with id: #{blob.id} - successfully generated.\n" \
|
||||
"Transformations applied: #{preview.variation.transformations}"
|
||||
|
||||
blob.attachments.take.record.update(file_processing: false)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue