Skip to content

Commit

Permalink
Mark records as skipped if we do not see them during an import run (#922
Browse files Browse the repository at this point in the history
)

* mark entries as skipped if they have not been seen during an importer run
  • Loading branch information
orangewolf authored Feb 10, 2024
1 parent 06bde07 commit 7bbb9b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/models/bulkrax/importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions app/models/concerns/bulkrax/status_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7bbb9b7

Please sign in to comment.