Sha256: 36826baa99168db30a3a9e7d4506752e30fa1e4198fdfc07beed7e549b51183e

Contents?: true

Size: 847 Bytes

Versions: 10

Compression:

Stored size: 847 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/letters"

module Renalware
  module Letters
    module Mailshots
      # A background job to create letter records for a mailshot.
      # More than 1000 letters in a mailshot could cause a timeout if executed
      # while the user waits, which is why processing is done in the background.
      class CreateMailshotLettersJob < ApplicationJob
        def perform(mailshot)
          mailshot.update_column(:status, :processing)
          mailshot.create_letters
          mailshot.update_columns(status: :success, last_error: nil)
        rescue StandardError => e
          mailshot.update_columns(
            last_error: "#{$ERROR_INFO}\nBacktrace:\n\t#{e.backtrace.join("\n\t")}",
            status: :failure
          )
          raise e
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.1.0 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.167 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.166 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.165 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.164 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.163 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.162 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.161 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.160 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb