Fail the import if the check fails

This commit is contained in:
Stanko K.R.
2026-02-02 13:33:06 +01:00
parent 2dbbeffdcf
commit 54a7ecea98
2 changed files with 5 additions and 1 deletions
+1
View File
@@ -2,6 +2,7 @@ class ImportAccountDataJob < ApplicationJob
include ActiveJob::Continuable
queue_as :backend
discard_on Account::DataTransfer::RecordSet::IntegrityError
def perform(import)
step :check do |step|
+4 -1
View File
@@ -8,7 +8,7 @@ class Account::Import < ApplicationRecord
enum :status, %w[ pending processing completed failed ].index_by(&:itself), default: :pending
scope :expired, -> { where(completed_at: ...24.hours.ago) }
scope :expired, -> { where(completed_at: ...24.hours.ago).or(where(status: :failed, created_at: ...7.days.ago)) }
def self.cleanup
expired.destroy_all
@@ -26,6 +26,9 @@ class Account::Import < ApplicationRecord
record_set.check(from: zip, start: last_id, callback: callback)
end
end
rescue => e
mark_as_failed
raise e
end
def process(start: nil, callback: nil)