diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb index be9dc0a7d..5a6971d10 100644 --- a/app/models/bulk_upload.rb +++ b/app/models/bulk_upload.rb @@ -11,6 +11,7 @@ class BulkUpload < ApplicationRecord has_many :sales_logs after_initialize :generate_identifier, unless: :identifier + after_initialize :initialize_processing, if: :new_record? scope :search_by_filename, ->(filename) { where("filename ILIKE ?", "%#{filename}%") } scope :search_by_user_name, ->(name) { where(user_id: User.where("name ILIKE ?", "%#{name}%").select(:id)) } @@ -155,4 +156,8 @@ private def generate_identifier self.identifier ||= SecureRandom.uuid end + + def initialize_processing + self.processing = true if processing.nil? + end end diff --git a/app/services/bulk_upload/processor.rb b/app/services/bulk_upload/processor.rb index 34ca3ce18..fa10b42e3 100644 --- a/app/services/bulk_upload/processor.rb +++ b/app/services/bulk_upload/processor.rb @@ -6,7 +6,6 @@ class BulkUpload::Processor end def call - bulk_upload.update!(processing: true) destroy_any_existing_errors_from_prior_run download