Skip to content
Snippets Groups Projects
Verified Commit 38db6d3d authored by Anusha Ranganathan's avatar Anusha Ranganathan Committed by Pascal Ernster
Browse files

Find failed entries for count and rake task

parent 6f98a963
No related merge requests found
Pipeline #14835 passed
......@@ -2,13 +2,17 @@ module BulkraxHelper
def rerun_failed_entries_in_last_run
current_run = @importer.last_run
if current_run&.failed_records&.positive?
failed_entries = []
@importer.entries.each do |entry|
next if entry.status == 'Complete'
failed_entries << entry
end
if failed_entries.any?
::Bulkrax::ScheduleRelationshipsJob.set(wait: 5.minutes).perform_later(importer_id: @importer.id)
@importer.status_info('Pending')
@importer.entries.each do |entry|
next if entry.status == 'Complete'
failed_entries.each do |entry|
type = if entry.raw_metadata['model'] == 'CrcDataset'
'Work'
else
......
namespace :rdms do
desc 'Rerun failed entries in last run of importer. usage: rdms:rerun_failed_entries_in_importer[importer_id]'
task :"rerun_failed_entries_in_importer", [:importer_id] => :environment do |task, args|
importer_id = args.importer_id
abort("ERROR: missing importer_id: #{importer_id}") unless importer_id.present?
importer_id = importer_id.to_s.strip
abort("ERROR: importer_id is not an integer: #{importer_id}") unless importer_id.to_i.to_s == importer_id
@importer = ::Bulkrax::Importer.find(importer_id)
include BulkraxHelper
rerun_failed_entries_in_last_run
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment