Class: Spotlight::RenameTagsJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- Spotlight::RenameTagsJob
- Includes:
- JobTracking
- Defined in:
- app/jobs/spotlight/rename_tags_job.rb
Instance Method Summary collapse
-
#perform(exhibit, tag, to: nil) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
Methods included from JobTracking
#finalize_job_tracker!, #initialize_job_tracker!, #job_tracker, #mark_job_as_failed!
Instance Method Details
#perform(exhibit, tag, to: nil) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/jobs/spotlight/rename_tags_job.rb', line 11 def perform(exhibit, tag, to: nil, **) @errors = 0 tag.taggings.owned_by(exhibit).find_each do |tagging| sidecar = tagging.taggable = sidecar. -= [tag.name] += [to] unless to.nil? exhibit.tag(sidecar, with: , on: :tags) sidecar.document.reindex(update_params: {}) rescue StandardError => e job_tracker.append_log_entry(type: :error, exhibit: exhibit, message: e.to_s) @errors += 1 mark_job_as_failed! end exhibit.blacklight_config.repository.connection.commit job_tracker.append_log_entry(type: :info, exhibit: exhibit, message: "#{progress.progress} of #{progress.total} (#{@errors} errors)") end |