fix(imports): check run ownership before heartbeat

This commit is contained in:
Sony Mathew
2026-07-23 14:38:23 +05:30
parent b8945e8d87
commit ea783a89ea
2 changed files with 2 additions and 3 deletions
@@ -190,8 +190,8 @@ class DataImports::Intercom::Importer
end
def continue_import_with_heartbeat?
return true if @data_import.updated_at > HEARTBEAT_INTERVAL.ago
return false if import_stopped?
return true if @data_import.updated_at > HEARTBEAT_INTERVAL.ago
@data_import.touch if @data_import.updated_at <= HEARTBEAT_INTERVAL.ago
true
@@ -315,8 +315,7 @@ RSpec.describe DataImports::Intercom::Importer do
allow(data_import).to receive(:touch).and_call_original
importer = described_class.new(data_import: data_import, run_id: run_id)
allow(importer).to receive(:create_message) do
data_import.update!(source_metadata: { DataImport::ACTIVE_INTERCOM_IMPORT_RUN_ID_KEY => 'new-run' })
travel 1.minute
DataImport.find(data_import.id).update!(source_metadata: { DataImport::ACTIVE_INTERCOM_IMPORT_RUN_ID_KEY => 'new-run' })
end
importer.import_conversations_page