allow to resent copy email

This commit is contained in:
Pete Matsyburka
2024-02-25 02:00:18 +02:00
parent 2bd023e5d0
commit fcd40308ee
14 changed files with 103 additions and 65 deletions
+21
View File
@@ -3,6 +3,8 @@
module Submissions
DEFAULT_SUBMITTERS_ORDER = 'random'
PRELOAD_ALL_PAGES_AMOUNT = 200
module_function
def search(submissions, keyword)
@@ -27,6 +29,25 @@ module Submissions
submission.save!
end
def preload_with_pages(submission)
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
submission
end
def create_from_emails(template:, user:, emails:, source:, mark_as_sent: false, params: {})
preferences = Submitters.normalize_preferences(user.account, user, params)