Sha256: 35cf3f43e5a7f086aee4bd452b927e7743f8d776d2098d4d66cbb3bc78b3ed84

Contents?: true

Size: 1.12 KB

Versions: 39

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Spotlight
  ###
  class RemoveTagsJob < Spotlight::ApplicationJob
    include Spotlight::JobTracking
    include Spotlight::GatherDocuments
    with_job_tracking(resource: ->(job) { job.arguments.last[:exhibit] })

    # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
    def perform(solr_params:, exhibit:, tags:, **)
      @errors = 0

      each_document(solr_params, exhibit) do |document|
        sidecar = document.sidecar(exhibit)
        all_tags = sidecar.all_tags_list
        all_tags -= tags
        exhibit.tag(document.sidecar(exhibit), with: all_tags, on: :tags)
        document.reindex(update_params: {})
        progress&.increment
      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
    # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
blacklight-spotlight-3.5.0.1 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.5.0 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.4.4.1 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.4.4 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.4.3 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.4.2.2 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.4.2.1 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.4.2 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.4.1 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.4.0 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.3.0 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.2.0 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.1.0 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.0.3 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.0.2 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.0.1 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.0.0 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.0.0.rc6 app/jobs/spotlight/remove_tags_job.rb
blacklight-spotlight-3.0.0.rc5 app/jobs/spotlight/remove_tags_job.rb