2024-10-09 17:48:45 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2024-10-10 13:23:25 +03:00
|
|
|
class GeneratePreviewImagesJob
|
2024-10-09 17:48:45 +03:00
|
|
|
include Sidekiq::Job
|
|
|
|
|
|
|
|
|
|
sidekiq_options queue: :images
|
|
|
|
|
|
|
|
|
|
def perform(params = {})
|
|
|
|
|
attachment = ActiveStorage::Attachment.find(params['attachment_id'])
|
|
|
|
|
|
|
|
|
|
max_page = [attachment.metadata['pdf']['number_of_pages'].to_i - 1,
|
|
|
|
|
Templates::ProcessDocument::MAX_NUMBER_OF_PAGES_PROCESSED].min
|
|
|
|
|
|
2025-10-04 18:33:37 +03:00
|
|
|
Templates::ProcessDocument.generate_document_preview_images(attachment, attachment.download, 1..max_page,
|
2024-10-09 17:48:45 +03:00
|
|
|
concurrency: 1)
|
|
|
|
|
end
|
|
|
|
|
end
|