mirror of https://github.com/docusealco/docuseal
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
843 B
30 lines
843 B
# frozen_string_literal: true
|
|
|
|
class SubmissionsPreviewController < ApplicationController
|
|
skip_before_action :authenticate_user!
|
|
skip_authorization_check
|
|
|
|
PRELOAD_ALL_PAGES_AMOUNT = 200
|
|
|
|
def show
|
|
@submission = Submission.find_by!(slug: params[:slug])
|
|
|
|
ActiveRecord::Associations::Preloader.new(
|
|
records: [@submission],
|
|
associations: [:template, { template_schema_documents: :blob }]
|
|
).call
|
|
|
|
total_pages =
|
|
@submission.template_schema_documents.sum { |e| e.metadata.dig('pdf', 'number_of_pages').to_i }
|
|
|
|
if total_pages < PRELOAD_ALL_PAGES_AMOUNT
|
|
ActiveRecord::Associations::Preloader.new(
|
|
records: @submission.template_schema_documents,
|
|
associations: [:blob, { preview_images_attachments: :blob }]
|
|
).call
|
|
end
|
|
|
|
render 'submissions/show', layout: 'plain'
|
|
end
|
|
end
|