From 7964466d4f63bb5f0de2ca9675a01e27beeb0db3 Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Thu, 8 Feb 2024 01:04:23 -0800 Subject: [PATCH 1/2] Found another place we need to include the monad lib. This time so that generators work --- spec/test_app/config/application.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/test_app/config/application.rb b/spec/test_app/config/application.rb index af0ed0959..bb6896ceb 100644 --- a/spec/test_app/config/application.rb +++ b/spec/test_app/config/application.rb @@ -11,6 +11,7 @@ require "action_cable/engine" # require "rails/test_unit/railtie" require "sprockets/railtie" +require 'dry/monads' Bundler.require(*Rails.groups) require "bulkrax" From 3c406428caf768cd369b8c8f04c97a0d37f77683 Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Thu, 8 Feb 2024 23:36:48 -0800 Subject: [PATCH 2/2] mark entries as skipped if they have not been seen during an importer run --- app/models/bulkrax/importer.rb | 9 +++++++++ app/models/concerns/bulkrax/status_info.rb | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/app/models/bulkrax/importer.rb b/app/models/bulkrax/importer.rb index 94c400f31..efa432954 100644 --- a/app/models/bulkrax/importer.rb +++ b/app/models/bulkrax/importer.rb @@ -195,10 +195,19 @@ def import_objects(types_array = nil) end end parser.create_objects(types) + mark_unseen_as_skipped rescue StandardError => e set_status_info(e) end + # 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| + entry.set_status_info('Skipped') + end + end + # Prepend the base_url to ensure unique set identifiers # @todo - move to parser, as this is OAI specific def unique_collection_identifier(id) diff --git a/app/models/concerns/bulkrax/status_info.rb b/app/models/concerns/bulkrax/status_info.rb index 02ce18838..c48dc58ea 100644 --- a/app/models/concerns/bulkrax/status_info.rb +++ b/app/models/concerns/bulkrax/status_info.rb @@ -13,6 +13,7 @@ module StatusInfo scope :failed, -> { where(status_message: 'Failed') } scope :complete, -> { where(status_message: 'Complete') } scope :pending, -> { where(status_message: 'Pending') } + scope :skipped, -> { where(status_message: 'Skipped') } end def current_status @@ -28,6 +29,10 @@ def succeeded? current_status&.status_message&.match(/^Complete$/) end + def skipped? + current_status&.status_message&.match('Skipped') + end + def status current_status&.status_message || 'Pending' end