app/models/spotlight/resources/dor_resource.rb in spotlight-dor-resources-0.2.1 vs app/models/spotlight/resources/dor_resource.rb in spotlight-dor-resources-0.2.2
- old
+ new
@@ -6,17 +6,17 @@
##
# Generate solr documents for the DOR resources identified by this object
#
# @return [Enumerator] an enumerator of solr document hashes for indexing
def to_solr
- return to_enum(:to_solr) { indexable_resources.size } unless block_given?
+ return to_enum(:to_solr) { size } unless block_given?
- benchmark "Indexing resource #{inspect}" do
+ benchmark "Indexing resource #{inspect} (est. #{size} items)" do
base_doc = super
indexable_resources.each_with_index do |res, idx|
- benchmark "Indexing item #{res.druid} in resource #{id} (#{idx})" do
+ benchmark "Indexing item #{res.druid} in resource #{id} (#{idx} / #{size})" do
yield base_doc.merge(to_solr_document(res))
end
end
end
end
@@ -38,9 +38,15 @@
yield resource
resource.items.each do |r|
yield r
end
+ end
+
+ ##
+ # Estimate the number of documents this resource will create
+ def size
+ indexable_resources.size
end
##
# Generate the solr document hash for a given resource by applying the current
# indexer steps.