Sha256: 26ffcf7cc57021ecfaec8509cc12eb1b32943b9aff3ed702d0da5c88758d67b8

Contents?: true

Size: 1.08 KB

Versions: 39

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

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

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

      each_document(solr_params, exhibit) do |document|
        case visibility
        when 'public'
          document.make_public!(exhibit)
        when 'private'
          document.make_private!(exhibit)
        end
        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/MethodLength
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
blacklight-spotlight-4.2.0 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-4.1.2 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-4.1.1 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-4.1.0 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-4.0.3 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-4.0.2 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-4.0.1 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-4.0.0 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-3.6.0.beta10 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-3.6.0.beta9 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-3.6.0.beta8 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-3.5.0.4 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-3.6.0.beta7 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-3.5.0.3 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-3.6.0.beta6 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-3.6.0.beta5 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-3.6.0.beta4 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-3.6.0.beta3 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-3.6.0.beta1 app/jobs/spotlight/change_visibility_job.rb
blacklight-spotlight-3.5.0.2 app/jobs/spotlight/change_visibility_job.rb