spotlight-dor-resources 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9c7b421a13eda5a5700db8c0bf1901f5f5838a3
|
4
|
+
data.tar.gz: 05e7e9e1f72e767085fb48df489843281bebfa1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84d0129c9e2a56a2f2962d659a63a6f1a861b771e32a4901704f1be5307dd57fffa57dab5595e71563fde33454b87d708af789e29f1ce90b91f251b28d2d8fe4
|
7
|
+
data.tar.gz: 445c27164425683a629d5fb7eea1aeb0327462bab585cdec08506060782486119d66e2e5ac02353c092d963653ed996f0b942cb7e66ea57b4380f16f7546c742
|
@@ -4,33 +4,22 @@ module Spotlight::Resources
|
|
4
4
|
include ActiveSupport::Benchmarkable
|
5
5
|
|
6
6
|
##
|
7
|
-
# Generate solr documents for the DOR resources identified by this object
|
7
|
+
# Generate solr documents for the DOR resources identified by this object
|
8
8
|
#
|
9
9
|
# @return [Enumerator] an enumerator of solr document hashes for indexing
|
10
|
-
|
11
|
-
def to_solr(&block)
|
10
|
+
def to_solr
|
12
11
|
return to_enum(:to_solr) { indexable_resources.size } unless block_given?
|
13
12
|
|
14
|
-
|
15
|
-
# but need to jump through some hoops to make it yield an enumerable in the end.
|
16
|
-
#
|
17
|
-
# Here, we create a hook that simply yields the result to the enumerable. We configure
|
18
|
-
# this as a 'finish' hook, which Parallel will run on the main process.
|
19
|
-
yield_to_enum = ->(_item, _i, result) { block.call(result) }
|
20
|
-
|
21
|
-
size = indexable_resources.size
|
22
|
-
|
23
|
-
benchmark "Indexing resource #{inspect} (est. #{size} items)" do
|
13
|
+
benchmark "Indexing resource #{inspect}" do
|
24
14
|
base_doc = super
|
25
15
|
|
26
|
-
|
27
|
-
benchmark "Indexing item #{res.druid} in resource #{id} (#{idx}
|
28
|
-
base_doc.merge(to_solr_document(res))
|
16
|
+
indexable_resources.each_with_index do |res, idx|
|
17
|
+
benchmark "Indexing item #{res.druid} in resource #{id} (#{idx})" do
|
18
|
+
yield base_doc.merge(to_solr_document(res))
|
29
19
|
end
|
30
20
|
end
|
31
21
|
end
|
32
22
|
end
|
33
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
34
23
|
|
35
24
|
def resource
|
36
25
|
@resource ||= Spotlight::Dor::Resources.indexer.resource doc_id
|
@@ -67,9 +56,5 @@ module Spotlight::Resources
|
|
67
56
|
def logger
|
68
57
|
Spotlight::Dor::Resources.indexer.logger
|
69
58
|
end
|
70
|
-
|
71
|
-
def parallel_options
|
72
|
-
Spotlight::Dor::Resources::Engine.config.parallel_options
|
73
|
-
end
|
74
59
|
end
|
75
60
|
end
|