Skip to content

Commit

Permalink
Allow the BibReader to return the size of the entire bibliography.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeck committed Oct 3, 2017
1 parent b6da25d commit 2c6ffb5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/services/bibliography_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ class BibliographyBuilder < Spotlight::SolrDocumentBuilder
include ActiveSupport::Benchmarkable
delegate :logger, to: :Rails

delegate :size, to: :traject_reader

def to_solr
return to_enum(:to_solr) unless block_given?
return to_enum(:to_solr) { size } unless block_given?

benchmark "Indexing resource #{inspect}" do
base_doc = super
Expand Down Expand Up @@ -37,8 +39,7 @@ def traject_indexer
private

def convert_id(doc)
return unless doc['id']
doc[:id] = doc['id'].first
doc[:id] = doc['id'].try(:first)
doc
end
end
3 changes: 3 additions & 0 deletions lib/traject/bib_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
class BibReader
# @param input_stream [File]
# @param settings [Traject::Indexer::Settings]

delegate :size, to: :bibtex

def initialize(input_stream, settings)
@settings = Traject::Indexer::Settings.new settings
@input_stream = input_stream
Expand Down

0 comments on commit 2c6ffb5

Please sign in to comment.