From 54a7ecea9876ec4cb47b87193b451e2b3ab6a8a2 Mon Sep 17 00:00:00 2001 From: "Stanko K.R." Date: Mon, 2 Feb 2026 13:33:06 +0100 Subject: [PATCH] Fail the import if the check fails --- app/jobs/import_account_data_job.rb | 1 + app/models/account/import.rb | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/jobs/import_account_data_job.rb b/app/jobs/import_account_data_job.rb index 5afa0b08f..6c2e5ff87 100644 --- a/app/jobs/import_account_data_job.rb +++ b/app/jobs/import_account_data_job.rb @@ -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| diff --git a/app/models/account/import.rb b/app/models/account/import.rb index ea34bf145..c0841b7fb 100644 --- a/app/models/account/import.rb +++ b/app/models/account/import.rb @@ -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)