This commit is contained in:
Matt Jankowski 2025-09-03 20:07:43 +00:00 committed by GitHub
commit 2631fc7e93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 3 deletions

View File

@ -53,7 +53,7 @@ class BulkImport < ApplicationRecord
BulkImport.increment_counter(:processed_items, bulk_import_id)
BulkImport.increment_counter(:imported_items, bulk_import_id) if imported
# Since the incrementation has been done atomically, concurrent access to `bulk_import` is now bening
# Since the incrementation has been done atomically, concurrent access to `bulk_import` is now benign
bulk_import = BulkImport.find(bulk_import_id)
bulk_import.update!(state: :finished, finished_at: Time.now.utc) if bulk_import.processed_items == bulk_import.total_items
end

View File

@ -67,9 +67,8 @@ class Form::Import
return false unless valid?
ApplicationRecord.transaction do
now = Time.now.utc
@bulk_import = current_account.bulk_imports.create(type: type, overwrite: overwrite || false, state: :unconfirmed, original_filename: data.original_filename, likely_mismatched: likely_mismatched?)
nb_items = BulkImportRow.insert_all(parsed_rows.map { |row| { bulk_import_id: bulk_import.id, data: row, created_at: now, updated_at: now } }).length
nb_items = @bulk_import.rows.insert_all(parsed_rows.map { |row| { data: row } }, record_timestamps: true).length
@bulk_import.update(total_items: nb_items)
end
end