fix updated templates

This commit is contained in:
Pete Matsyburka
2024-10-29 12:11:21 +02:00
parent d4aef79b68
commit 6a298a068c
+7 -1
View File
@@ -25,9 +25,15 @@ module Templates
name: :preview_images)
.preload(:blob)
json[:documents] = template.schema.map do |item|
json[:documents] = template.schema.filter_map do |item|
attachment = schema_documents.find { |e| e.uuid == item['attachment_uuid'] }
unless attachment
Rollbar.error("Documents missing: #{template.id}") if defined?(Rollbar)
next
end
first_page_blob = preview_image_attachments.find { |e| e.record_id == attachment.id }&.blob
first_page_blob ||= attachment.preview_images.joins(:blob).find_by(blob: { filename: ['0.jpg', '0.png'] })&.blob