diff --git a/app/jobs/bibliographic_job.rb b/app/jobs/bibliographic_job.rb index 3920f7fc..c679e6df 100644 --- a/app/jobs/bibliographic_job.rb +++ b/app/jobs/bibliographic_job.rb @@ -2,12 +2,14 @@ class BibliographicJob < ApplicationJob queue_as :default def perform(host_bib_task) + current = nil host_bib_task.host_bibs.where(marc_status: %w[pending retrieving]).find_each do |host_bib| + current = host_bib Bibliographic::HostBib.create_linked_bibs(host_bib) end after_perform_upload!(host_bib_task) rescue StandardError => e - mark_failed_and_notify!(e, host_bib_task) + mark_failed_and_notify!(e, host_bib_task, current) end private @@ -25,12 +27,13 @@ def generate_attatchments(host_bib_task) attachment_hash end - def mark_failed_and_notify!(e, host_bib_task) + def mark_failed_and_notify!(e, host_bib_task, host_bib) host_bib_task.failed! subject = 'Host Bibliographic Upload - Failed' - message = 'Host Bibliographic upload failed, please reach out to our support team.' - RequestMailer.bibliographic_email(host_bib_task.email, [], subject, message).deliver_now - logger.error "BibliographicJob failed: #{e.message}" + RequestMailer.bibliographic_failure_email(host_bib_task.email, subject, host_bib_task, host_bib).deliver_now + mms_id = host_bib&.mms_id + filename = File.basename(host_bib_task.filename) + logger.error "BibliographicJob failed processing #{mms_id} in #{filename}: #{e.message}" raise e end diff --git a/app/mailers/request_mailer.rb b/app/mailers/request_mailer.rb index 17ec7384..02b7f73c 100644 --- a/app/mailers/request_mailer.rb +++ b/app/mailers/request_mailer.rb @@ -232,6 +232,12 @@ def bibliographic_email(email, attachment_contents, subject, body) mail(to: email, subject:, body:) end + def bibliographic_failure_email(email, subject, host_bib_task, host_bib) + @host_bib_task = host_bib_task + @host_bib = host_bib + mail(to: email, subject:) + end + def efee_invoice_email(alma_id) efee = EfeesInvoice.new(alma_id) # type probably isn't needed now that I spun this off to a separate url diff --git a/app/views/request_mailer/bibliographic_failure_email.html.erb b/app/views/request_mailer/bibliographic_failure_email.html.erb new file mode 100644 index 00000000..ed37c6f9 --- /dev/null +++ b/app/views/request_mailer/bibliographic_failure_email.html.erb @@ -0,0 +1,24 @@ + + +
+ + + + +