Module: Spotlight::GatherDocuments
- Extended by:
- ActiveSupport::Concern
- Included in:
- AddTagsJob, ChangeVisibilityJob, RemoveTagsJob
- Defined in:
- app/jobs/concerns/spotlight/gather_documents.rb
Overview
Gather documents by a given query that can be used in a job Will also increment job tracking total
Instance Method Summary collapse
-
#each_document(solr_params, exhibit, &block) ⇒ Object
rubocop:disable Metrics/MethodLength.
Instance Method Details
#each_document(solr_params, exhibit, &block) ⇒ Object
rubocop:disable Metrics/MethodLength
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/jobs/concerns/spotlight/gather_documents.rb', line 10 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 |