From b1755c4d5b968d69dc117bd5cc4d718ba9cf7a04 Mon Sep 17 00:00:00 2001 From: Suzanne Vogt Date: Mon, 29 Jun 2020 10:44:36 -0400 Subject: [PATCH] Issues #42, #43, #52, #53 - Try bulkrax, overrides for NoMethodErrors on import (bulkrax/zizia), Bulkrax import bugs, sidekiq performance issues. --- Gemfile | 1 - app/overrides/bulkrax/oai_dc_parser.rb | 3 ++ .../file_set_attached_event_job_prepends.rb | 29 +++++++++++++++++++ config/sidekiq.yml | 3 +- 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 app/overrides/zizia/file_set_attached_event_job_prepends.rb diff --git a/Gemfile b/Gemfile index aa29ffd..5f45359 100644 --- a/Gemfile +++ b/Gemfile @@ -64,7 +64,6 @@ gem 'jquery-rails' gem 'devise' gem 'sidekiq' - gem 'devise-guests', '~> 0.6' group :development, :test do gem 'fcrepo_wrapper' diff --git a/app/overrides/bulkrax/oai_dc_parser.rb b/app/overrides/bulkrax/oai_dc_parser.rb index f9a388d..9eaa429 100644 --- a/app/overrides/bulkrax/oai_dc_parser.rb +++ b/app/overrides/bulkrax/oai_dc_parser.rb @@ -18,10 +18,12 @@ def create_works # CODE BLOCK 1 # +#=begin seen[record.identifier] = true new_entry = entry_class.where(importerexporter: self.importerexporter, identifier: record.identifier).first_or_create! ImportWorkJob.send(perform_method, new_entry.id, importerexporter.current_importer_run.id) increment_counters(index) +#=end # Use either code block 1 or code block 2, not both. # Eventually, direction for this should come from the importer form. We should customize the importer form for this. @@ -46,6 +48,7 @@ def create_works end =end + end end end diff --git a/app/overrides/zizia/file_set_attached_event_job_prepends.rb b/app/overrides/zizia/file_set_attached_event_job_prepends.rb new file mode 100644 index 0000000..536182f --- /dev/null +++ b/app/overrides/zizia/file_set_attached_event_job_prepends.rb @@ -0,0 +1,29 @@ +require_dependency Zizia::Engine.config.root.join('config', 'initializers', 'file_set_attached_event_job_prepends.rb').to_s + +module FileSetAttachedEventJobPrepends + def action + if repo_object.kind_of?(FileSet) + + # Override - returns if no files in file_set. Prevents NoMethodError('size') on 'pre_ingest_file = ...' below. + if repo_object.files.first.nil? + return + end + + pre_ingest_work_id = Zizia::PreIngestWork.find_by(deduplication_key: curation_concern.deduplication_key) + pre_ingest_file = Zizia::PreIngestFile.find_by(size: repo_object.files.first.size, + filename: repo_object.files.first.original_name, + pre_ingest_work_id: pre_ingest_work_id) + + # Override - returns if no files in file_set. Prevents NoMethodError('status=') on 'pre_ingest_file.status = ...' below. + if curation_concern.deduplication_key.nil? + return + end + + pre_ingest_file.status = 'attached' + pre_ingest_file.save + end + end +end + + + diff --git a/config/sidekiq.yml b/config/sidekiq.yml index b0f3d35..1709d65 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -1,5 +1,6 @@ #:concurrency: 3 -:concurrency: 1 +#:concurrency: 3 +:concurrency: <%= ENV['SIDEKIQ_MAX_THREADS'] || '3' %> :queues: - default - import