From f5cd0fdcbbfc8527d8ff4ec2ba5abe70b8006841 Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Fri, 9 Feb 2024 14:41:08 -0800 Subject: [PATCH] fixes skip and do not show existing entry option on new importer --- Rakefile | 14 +++++++------- app/models/bulkrax/importer.rb | 2 +- app/views/bulkrax/importers/_csv_fields.html.erb | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Rakefile b/Rakefile index 41f4f9cd1..6dc616de5 100644 --- a/Rakefile +++ b/Rakefile @@ -25,18 +25,18 @@ require 'bundler/gem_tasks' require 'solr_wrapper/rake_task' unless Rails.env.production? +require 'rubocop/rake_task' + +RuboCop::RakeTask.new(:rubocop) do |t| + t.options = ['--display-cop-names', '--ignore-parent-exclusion', '-a'] +end + begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) - task default: :spec + task default: [:rubocop, :spec] rescue LoadError # rubocop:disable Lint/HandleExceptions # no rspec available end - -require 'rubocop/rake_task' - -RuboCop::RakeTask.new(:rubocop) do |t| - t.options = ['--display-cop-names'] -end diff --git a/app/models/bulkrax/importer.rb b/app/models/bulkrax/importer.rb index 7618de90f..e24320380 100644 --- a/app/models/bulkrax/importer.rb +++ b/app/models/bulkrax/importer.rb @@ -202,7 +202,7 @@ def import_objects(types_array = nil) # After an import any entries we did not touch are skipped. # They are not really pending, complete for the last run, or failed def mark_unseen_as_skipped - entries.where.not(id. seen).find_each do |entry| + entries.where.not(identifier: seen.keys).find_each do |entry| entry.set_status_info('Skipped') end end diff --git a/app/views/bulkrax/importers/_csv_fields.html.erb b/app/views/bulkrax/importers/_csv_fields.html.erb index 88dcd61ba..faf96d4be 100644 --- a/app/views/bulkrax/importers/_csv_fields.html.erb +++ b/app/views/bulkrax/importers/_csv_fields.html.erb @@ -25,7 +25,9 @@

Add CSV File to Import:

<%# accept a single file upload; data files and bags will need to be added another way %> - <%= fi.input :file_style, collection: ['Upload a File', 'Specify a Path on the Server', 'Existing Entries'], as: :radio_buttons, label: false %> + <% file_style_list = ['Upload a File', 'Specify a Path on the Server'] %> + <% file_style_list << 'Existing Entries' unless importer.new_record? %> + <%= fi.input :file_style, collection: file_style_list, as: :radio_buttons, label: false %>
<%= fi.input 'file', as: :file, input_html: { accept: 'text/csv,application/zip' } %>