Sha256: d89a7894b558f286093559822f7bc5674c1b3fc6751bc6fc4c782ebd28580995

Contents?: true

Size: 1.09 KB

Versions: 46

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module Spotlight
  # Gather documents by a given query that can be used in a job
  # Will also increment job tracking total
  module GatherDocuments
    extend ActiveSupport::Concern

    # rubocop:disable Metrics/MethodLength
    def each_document(solr_params, exhibit, &block)
      return to_enum(:each_document, solr_params, exhibit) unless block_given?

      cursor_mark = nil
      next_cursor_mark = '*'

      until next_cursor_mark == cursor_mark || next_cursor_mark.nil?
        cursor_mark = next_cursor_mark
        response = exhibit.blacklight_config.repository.search(
          solr_params.merge(
            'rows' => Spotlight::Engine.config.bulk_actions_batch_size,
            'cursorMark' => cursor_mark,
            'sort' => "#{exhibit.blacklight_config.document_model.unique_key} asc"
          )
        )
        progress.total = response.total
        response.documents.each do |document|
          block.call(document)
        end

        next_cursor_mark = response['nextCursorMark']
      end
    end
    # rubocop:enable Metrics/MethodLength
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
blacklight-spotlight-4.3.6 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.3.5 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.3.4 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.3.3 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.3.2 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.3.1 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.3.0 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.2.0 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.1.2 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.1.1 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.1.0 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.0.3 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.0.2 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.0.1 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-4.0.0 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-3.6.0.beta10 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-3.6.0.beta9 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-3.6.0.beta8 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-3.5.0.4 app/jobs/concerns/spotlight/gather_documents.rb
blacklight-spotlight-3.6.0.beta7 app/jobs/concerns/spotlight/gather_documents.rb