pull/349/head
Pete Matsyburka 1 year ago
parent 637011d55a
commit d135c93939

@ -9,9 +9,17 @@ module Templates
module_function module_function
def call(template, schema_documents = template.schema_documents, preview_image_attachments = []) def call(template, schema_documents = template.schema_documents.preload(:blob), preview_image_attachments = nil)
json = template.as_json(SERIALIZE_PARAMS) json = template.as_json(SERIALIZE_PARAMS)
preview_image_attachments ||=
ActiveStorage::Attachment.joins(:blob)
.where(blob: { filename: '0.jpg' })
.where(record_id: schema_documents.map(&:id),
record_type: 'ActiveStorage::Attachment',
name: :preview_images)
.preload(:blob)
json[:documents] = template.schema.map do |item| json[:documents] = template.schema.map do |item|
attachment = schema_documents.find { |e| e.uuid == item['attachment_uuid'] } attachment = schema_documents.find { |e| e.uuid == item['attachment_uuid'] }

Loading…
Cancel
Save