Sha256: f5fb4db592f8818bb91d73259e218375f31b4ba957a24da70c5d8acb949e8e76

Contents?: true

Size: 869 Bytes

Versions: 12

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/letters"
require "attr_extras"

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

12 entries across 12 versions & 1 rubygems

Version Path
renalware-core-2.0.159 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.158 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.157 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.156 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.155 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.153 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.152 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.151 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.149 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.148 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.147 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb
renalware-core-2.0.146 app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb