dor_indexing 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c1e2280668e9085122b921fd927b75e9982fa5fda9067a9245899ef93db77ae
4
- data.tar.gz: 3e8d89e77994cb62ffcc1c598e47716c3a9c9f8aa8e37f226159e8fef947082d
3
+ metadata.gz: ae485a8233c79356bffbc42bef8d8e9f3ef1afbf3db962a2ba43b4ce522d7cd7
4
+ data.tar.gz: 1a05728e58b24d5f94164881a92326c9232402e241ce589dab14231e448ce60a
5
5
  SHA512:
6
- metadata.gz: 24e3bf95ad1c541d3b403b2233018ab1da89be80cdcd3fa9acb2793e2b57673c8364202a4a548f8fe1c9ff60444585b5cf2d020968cb5b50614ad80b118d7bae
7
- data.tar.gz: 6c015737932b1f01819d89f5f91948ab43d09e1537d6bf41ba8df85778c9ed0f18dc85b408a7fdc6ceb48ce6cfc4f7127b74da0c415aac6819d7dd460cf8a4eb
6
+ metadata.gz: 24cfdc3e6be2af97c092e893825af54f8e3e3e47d65b9b955ea90c4ebda86072dbd87f32e2b3778e5fbee005be00c6877efac710e4d87b178f2521cee42f8b62
7
+ data.tar.gz: 7a1fc488f95678830e07fb919371e3ef8f5125d8bfcbf40d62109c51f87203fb6c424bef4da4fd8b7a9ec77a87bfee3f92274325482ab58d602599d069bbafe7
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dor_indexing (1.4.1)
4
+ dor_indexing (1.5.0)
5
5
  activesupport
6
6
  cocina-models (~> 0.95.1)
7
+ dor-services-client (~> 14.0)
7
8
  dor-workflow-client (~> 7.0)
8
9
  honeybadger
9
10
  marc-vocab (~> 0.3.0)
@@ -26,7 +27,7 @@ GEM
26
27
  ast (2.4.2)
27
28
  attr_extras (7.1.0)
28
29
  base64 (0.2.0)
29
- bigdecimal (3.1.6)
30
+ bigdecimal (3.1.7)
30
31
  byebug (11.1.3)
31
32
  cocina-models (0.95.1)
32
33
  activesupport
@@ -51,6 +52,13 @@ GEM
51
52
  activesupport
52
53
  diff-lcs (1.5.1)
53
54
  docile (1.4.0)
55
+ dor-services-client (14.4.0)
56
+ activesupport (>= 4.2, < 8)
57
+ cocina-models (~> 0.95.1)
58
+ deprecation
59
+ faraday (~> 2.0)
60
+ faraday-retry
61
+ zeitwerk (~> 2.1)
54
62
  dor-workflow-client (7.0.2)
55
63
  activesupport (>= 3.2.1, < 8)
56
64
  deprecation (>= 0.99.0)
@@ -89,7 +97,7 @@ GEM
89
97
  net-http
90
98
  faraday-retry (2.2.0)
91
99
  faraday (~> 2.0)
92
- honeybadger (5.6.0)
100
+ honeybadger (5.8.0)
93
101
  i18n (1.14.4)
94
102
  concurrent-ruby (~> 1.0)
95
103
  ice_nine (0.11.2)
@@ -99,7 +107,7 @@ GEM
99
107
  multi_json
100
108
  language_server-protocol (3.17.0.3)
101
109
  marc-vocab (0.3.0)
102
- minitest (5.22.2)
110
+ minitest (5.22.3)
103
111
  mods (3.0.4)
104
112
  edtf (~> 3.0)
105
113
  iso-639
@@ -109,9 +117,9 @@ GEM
109
117
  mutex_m (0.2.0)
110
118
  net-http (0.4.1)
111
119
  uri
112
- nokogiri (1.16.2-x86_64-darwin)
120
+ nokogiri (1.16.3-x86_64-darwin)
113
121
  racc (~> 1.4)
114
- nokogiri (1.16.2-x86_64-linux)
122
+ nokogiri (1.16.3-x86_64-linux)
115
123
  racc (~> 1.4)
116
124
  nom-xml (1.2.0)
117
125
  i18n
@@ -146,7 +154,7 @@ GEM
146
154
  rspec-support (3.13.1)
147
155
  rss (0.3.0)
148
156
  rexml
149
- rubocop (1.62.0)
157
+ rubocop (1.62.1)
150
158
  json (~> 2.3)
151
159
  language_server-protocol (>= 3.17.0)
152
160
  parallel (~> 1.10)
data/README.md CHANGED
@@ -26,12 +26,25 @@ If bundler is not being used to manage dependencies, install the gem by executin
26
26
 
27
27
  ## Usage
28
28
 
29
- DorIndexing that a configured Workflow Client and a Cocina Repository be injected.
29
+ DorIndexing that a configured Workflow Client, DOR Services Client, and a Cocina Repository be injected.
30
30
 
31
31
  The Cocina Repository provides methods for finding Cocina objects and administrative tags. One possible implementation of a Cocina Repository would be to use DOR Services Client.
32
32
 
33
33
  ```ruby
34
34
  require 'dor_indexing'
35
35
 
36
- doc = DorIndexing.build(cocina_with_metadata:, workflow_client:, cocina_repository:)
36
+ doc = DorIndexing.build(cocina_with_metadata:, workflow_client:, dor_services_client:, cocina_repository:)
37
37
  ```
38
+
39
+ ## Testing
40
+
41
+ ### Integration Testing with Solr
42
+
43
+ We build and update the Solr index via dor-indexing-app amd dor-services-app, both of which use this gem for indexing logic.
44
+
45
+ Argo is the blacklight app that uses the Solr index extensively, and it already has the docker containers to create new test objects in dor-services-app and index them (via dor_indexing_app to Solr). And Argo is the app built on top of the Solr index, so a good place to check results.
46
+
47
+ To ensure our indexing behavior produces the desired results, it was easiest to put
48
+ the full stack integration tests in the argo repository -- they can be found in
49
+ https://github.com/sul-dlss/argo/tree/main/spec/features/indexing_xxx_spec.rb
50
+
data/dor_indexing.gemspec CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
33
33
 
34
34
  spec.add_dependency 'activesupport'
35
35
  spec.add_dependency 'cocina-models', '~> 0.95.1'
36
+ spec.add_dependency 'dor-services-client', '~> 14.0'
36
37
  spec.add_dependency 'dor-workflow-client', '~> 7.0'
37
38
  spec.add_dependency 'honeybadger'
38
39
  spec.add_dependency 'marc-vocab', '~> 0.3.0'
@@ -48,17 +48,18 @@ class DorIndexing
48
48
 
49
49
  @@parent_collections = {} # rubocop:disable Style/ClassVars
50
50
 
51
- def self.for(model:, workflow_client:, cocina_repository:)
52
- new(model:, workflow_client:, cocina_repository:).for
51
+ def self.for(model:, workflow_client:, dor_services_client:, cocina_repository:)
52
+ new(model:, workflow_client:, dor_services_client:, cocina_repository:).for
53
53
  end
54
54
 
55
55
  def self.reset_parent_collections
56
56
  @@parent_collections = {} # rubocop:disable Style/ClassVars
57
57
  end
58
58
 
59
- def initialize(model:, workflow_client:, cocina_repository:)
59
+ def initialize(model:, workflow_client:, dor_services_client:, cocina_repository:)
60
60
  @model = model
61
61
  @workflow_client = workflow_client
62
+ @dor_services_client = dor_services_client
62
63
  @cocina_repository = cocina_repository
63
64
  end
64
65
 
@@ -69,12 +70,13 @@ class DorIndexing
69
70
  parent_collections:,
70
71
  administrative_tags:,
71
72
  workflow_client:,
73
+ dor_services_client:,
72
74
  cocina_repository:)
73
75
  end
74
76
 
75
77
  private
76
78
 
77
- attr_reader :model, :workflow_client, :cocina_repository
79
+ attr_reader :model, :workflow_client, :dor_services_client, :cocina_repository
78
80
 
79
81
  def id
80
82
  model.externalIdentifier
@@ -4,11 +4,12 @@ class DorIndexing
4
4
  module Indexers
5
5
  # Indexes the object's release tags
6
6
  class ReleasableIndexer
7
- attr_reader :cocina, :parent_collections
7
+ attr_reader :cocina, :parent_collections, :dor_services_client
8
8
 
9
- def initialize(cocina:, parent_collections:, **)
9
+ def initialize(cocina:, parent_collections:, dor_services_client:, **)
10
10
  @cocina = cocina
11
11
  @parent_collections = parent_collections
12
+ @dor_services_client = dor_services_client
12
13
  end
13
14
 
14
15
  # @return [Hash] the partial solr document for releasable concerns
@@ -40,8 +41,11 @@ class DorIndexing
40
41
 
41
42
  def tags_from_collection
42
43
  parent_collections.each_with_object({}) do |collection, result|
43
- Array(collection.administrative.releaseTags)
44
- .select { |tag| tag.what == 'collection' }
44
+ collection_object_client = dor_services_client.object(collection.externalIdentifier)
45
+ collection_object_client
46
+ .release_tags
47
+ .list
48
+ .select { |tag| tag.what == 'self' }
45
49
  .group_by(&:to).map do |project, releases_for_project|
46
50
  result[project] = releases_for_project.max_by(&:date)
47
51
  end
@@ -49,13 +53,14 @@ class DorIndexing
49
53
  end
50
54
 
51
55
  def tags_from_item
52
- released_for.group_by(&:to).transform_values do |releases_for_project|
53
- releases_for_project.max_by(&:date)
54
- end
55
- end
56
-
57
- def released_for
58
- Array(cocina.administrative.releaseTags)
56
+ object_client = dor_services_client.object(cocina.externalIdentifier)
57
+ object_client
58
+ .release_tags
59
+ .list
60
+ .select { |tag| tag.what == 'self' }
61
+ .group_by(&:to).transform_values do |releases_for_project|
62
+ releases_for_project.max_by(&:date)
63
+ end
59
64
  end
60
65
  end
61
66
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class DorIndexing
4
- VERSION = '1.4.1'
4
+ VERSION = '1.5.0'
5
5
  end
data/lib/dor_indexing.rb CHANGED
@@ -10,14 +10,20 @@ require 'active_support/core_ext/object/blank'
10
10
  require 'active_support/core_ext/enumerable'
11
11
  require 'active_support/core_ext/string'
12
12
  require 'cocina/models'
13
+ require 'dor/services/client'
13
14
  require 'honeybadger'
14
15
  require 'marc/vocab'
15
16
 
16
17
  # Builds solr documents for indexing.
17
18
  class DorIndexing
18
19
  # @return [Hash] the solr document
19
- def self.build(cocina_with_metadata:, workflow_client:, cocina_repository:)
20
+ def self.build(cocina_with_metadata:, workflow_client:, dor_services_client:, cocina_repository:)
20
21
  Honeybadger.context({ identifier: cocina_with_metadata.externalIdentifier })
21
- DorIndexing::Builders::DocumentBuilder.for(model: cocina_with_metadata, workflow_client:, cocina_repository:).to_solr
22
+ DorIndexing::Builders::DocumentBuilder.for(
23
+ model: cocina_with_metadata,
24
+ workflow_client:,
25
+ dor_services_client:,
26
+ cocina_repository:
27
+ ).to_solr
22
28
  end
23
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor_indexing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Littman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-11 00:00:00.000000000 Z
11
+ date: 2024-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.95.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: dor-services-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '14.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '14.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: dor-workflow-client
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -180,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
194
  - !ruby/object:Gem::Version
181
195
  version: '0'
182
196
  requirements: []
183
- rubygems_version: 3.4.10
197
+ rubygems_version: 3.4.18
184
198
  signing_key:
185
199
  specification_version: 4
186
200
  summary: Library for creating Solr documents for SDR indexing.