active-fedora 11.1.1 → 11.1.2
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 +4 -4
- data/.travis.yml +2 -0
- data/History.txt +11 -0
- data/lib/active_fedora.rb +16 -1
- data/lib/active_fedora/aggregation/base_extension.rb +3 -1
- data/lib/active_fedora/associations/collection_association.rb +1 -1
- data/lib/active_fedora/associations/contained_finder.rb +2 -1
- data/lib/active_fedora/associations/rdf.rb +1 -1
- data/lib/active_fedora/null_logger.rb +5 -0
- data/lib/active_fedora/railtie.rb +1 -0
- data/lib/active_fedora/solr_service.rb +3 -0
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/indexing_spec.rb +1 -1
- data/spec/integration/query_result_builder_spec.rb +2 -2
- data/spec/lib/active_fedora/null_logger_spec.rb +10 -0
- data/spec/unit/solr_service_spec.rb +12 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b27e9aa8b8f46d2a0e3207ba20da3aa25d553bac
|
4
|
+
data.tar.gz: 8aac94771d8015432aa789bf807e514c6211be15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bc2ac85b840d7a5c8085a3d80d6407a6e3f315bf51fe7bd804b29818e375a939c9baf71560e6c1459f149d6cc6835af14e71128229d3255d87edaf818d3851e
|
7
|
+
data.tar.gz: d0c5f0849a3de8577174e28feda066fa61c53f5a8d30b6d27b6ffc1c2f4eb45c4c353a8ff6a188afb36eec98ebcac5f3111da7cbe0c51c9bd875b719b55420e7
|
data/.travis.yml
CHANGED
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
v11.1.2
|
2
|
+
2017-01-25: Eager load all the code in eager_load blocks [Justin Coyne]
|
3
|
+
|
4
|
+
2017-01-25: Eager load ActiveFedora [Justin Coyne]
|
5
|
+
|
6
|
+
2017-01-24: Ensuring up to date system gems [Jeremy Friesen]
|
7
|
+
|
8
|
+
2017-01-18: Warn if you don't pass :rows to SolrService.query [Justin Coyne]
|
9
|
+
|
10
|
+
2017-01-13: Ensuring NullLogger responds to logging questions [Jeremy Friesen]
|
11
|
+
|
1
12
|
v11.1.1
|
2
13
|
2017-01-13: Don't modify passed in attributes [Justin Coyne]
|
3
14
|
|
data/lib/active_fedora.rb
CHANGED
@@ -72,7 +72,6 @@ module ActiveFedora #:nodoc:
|
|
72
72
|
autoload :FilePersistence
|
73
73
|
autoload :FileRelation
|
74
74
|
autoload :FilesHash
|
75
|
-
autoload :Filter
|
76
75
|
autoload :FixityService
|
77
76
|
autoload :Identifiable
|
78
77
|
autoload :Indexers
|
@@ -263,6 +262,22 @@ module ActiveFedora #:nodoc:
|
|
263
262
|
true
|
264
263
|
end
|
265
264
|
end
|
265
|
+
|
266
|
+
# ActiveSupport::Autoload automatically defines
|
267
|
+
# an eager_load! method. In this case, we are
|
268
|
+
# extending the method to also eager load the
|
269
|
+
# components inside ActiveFedora.
|
270
|
+
def eager_load!
|
271
|
+
super
|
272
|
+
ActiveFedora::Scoping.eager_load!
|
273
|
+
ActiveFedora::Aggregation.eager_load!
|
274
|
+
ActiveFedora::Associations.eager_load!
|
275
|
+
ActiveFedora::Attributes.eager_load!
|
276
|
+
ActiveFedora::AttributeMethods.eager_load!
|
277
|
+
ActiveFedora::Indexers.eager_load!
|
278
|
+
ActiveFedora::Indexing.eager_load!
|
279
|
+
ActiveFedora::Orders.eager_load!
|
280
|
+
end
|
266
281
|
end
|
267
282
|
|
268
283
|
self.configurator ||= ActiveFedora::FileConfigurator.new
|
@@ -8,7 +8,9 @@ module ActiveFedora::Aggregation
|
|
8
8
|
|
9
9
|
def ordered_by_ids
|
10
10
|
if id.present?
|
11
|
-
|
11
|
+
query = "{!join from=proxy_in_ssi to=id}ordered_targets_ssim:#{id}"
|
12
|
+
rows = ActiveFedora::SolrService::MAX_ROWS
|
13
|
+
ActiveFedora::SolrService.query(query, rows: rows).map { |x| x["id"] }
|
12
14
|
else
|
13
15
|
[]
|
14
16
|
end
|
@@ -301,7 +301,7 @@ module ActiveFedora
|
|
301
301
|
def find_target
|
302
302
|
# TODO: don't reify, just store the solr results and lazily reify.
|
303
303
|
# For now, we set a hard limit of 1000 results.
|
304
|
-
records = ActiveFedora::QueryResultBuilder.reify_solr_results(load_from_solr(rows:
|
304
|
+
records = ActiveFedora::QueryResultBuilder.reify_solr_results(load_from_solr(rows: SolrService::MAX_ROWS))
|
305
305
|
records.each { |record| set_inverse_instance(record) }
|
306
306
|
records
|
307
307
|
rescue ObjectNotFoundError, Ldp::Gone => e
|
@@ -42,7 +42,8 @@ module ActiveFedora::Associations
|
|
42
42
|
query = ActiveFedora::SolrQueryBuilder.construct_query_for_rel(
|
43
43
|
[[:has_model, proxy_class.to_rdf_representation], [:proxyFor, record.id]]
|
44
44
|
)
|
45
|
-
ActiveFedora::SolrService
|
45
|
+
rows = ActiveFedora::SolrService::MAX_ROWS
|
46
|
+
ActiveFedora::SolrService.query(query, fl: 'id', rows: rows).map(&:rdf_uri)
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
@@ -61,7 +61,7 @@ module ActiveFedora
|
|
61
61
|
def filter_by_class(candidate_uris)
|
62
62
|
return [] if candidate_uris.empty?
|
63
63
|
ids = candidate_uris.map { |uri| ActiveFedora::Base.uri_to_id(uri) }
|
64
|
-
results = ActiveFedora::SolrService.query(ActiveFedora::SolrQueryBuilder.construct_query_for_ids(ids), rows:
|
64
|
+
results = ActiveFedora::SolrService.query(ActiveFedora::SolrQueryBuilder.construct_query_for_ids(ids), rows: SolrService::MAX_ROWS)
|
65
65
|
|
66
66
|
results.select { |result| result.model? reflection.klass }.map(&:rdf_uri)
|
67
67
|
end
|
@@ -6,5 +6,10 @@ module ActiveFedora
|
|
6
6
|
# allows all the usual logger method calls (warn, info, error, etc.)
|
7
7
|
def add(*)
|
8
8
|
end
|
9
|
+
|
10
|
+
# In the NullLogger there are no levels, so none of these should be true.
|
11
|
+
[:debug?, :info?, :warn?, :error?, :fatal?].each do |method_name|
|
12
|
+
define_method(method_name) { false }
|
13
|
+
end
|
9
14
|
end
|
10
15
|
end
|
@@ -2,6 +2,7 @@ module ActiveFedora
|
|
2
2
|
class Railtie < Rails::Railtie
|
3
3
|
config.app_middleware.insert_after ::ActionDispatch::Callbacks,
|
4
4
|
ActiveFedora::LdpCache
|
5
|
+
config.eager_load_namespaces << ActiveFedora
|
5
6
|
|
6
7
|
initializer 'active_fedora.autoload', before: :set_autoload_paths do |app|
|
7
8
|
app.config.autoload_paths << 'app/models/datastreams'
|
@@ -4,6 +4,8 @@ module ActiveFedora
|
|
4
4
|
class SolrService
|
5
5
|
attr_writer :conn
|
6
6
|
|
7
|
+
MAX_ROWS = 10_000
|
8
|
+
|
7
9
|
def initialize(options = {})
|
8
10
|
@options = { read_timeout: 120, open_timeout: 120, url: 'http://localhost:8080/solr' }.merge(options)
|
9
11
|
end
|
@@ -42,6 +44,7 @@ module ActiveFedora
|
|
42
44
|
end
|
43
45
|
|
44
46
|
def query(query, args = {})
|
47
|
+
Base.logger.warn "Calling ActiveFedora::SolrService.get without passing an explicit value for ':rows' is not recommended. You will end up with Solr's default (usually set to 10)\nCalled by #{caller[0]}" unless args.key?(:rows)
|
45
48
|
result = get(query, args)
|
46
49
|
result['response']['docs'].map do |doc|
|
47
50
|
ActiveFedora::SolrHit.new(doc)
|
@@ -83,7 +83,7 @@ describe ActiveFedora::Base do
|
|
83
83
|
before { gf.update(permissions_attributes: [{ id: p1.id, _destroy: 'true' }]) }
|
84
84
|
|
85
85
|
it "saves to solr correctly" do
|
86
|
-
result = ActiveFedora::SolrService.query("id:#{gf.id}").first['permissions_ssim']
|
86
|
+
result = ActiveFedora::SolrService.query("id:#{gf.id}", rows: 10).first['permissions_ssim']
|
87
87
|
expect(result).to eq [p2.id]
|
88
88
|
end
|
89
89
|
end
|
@@ -19,7 +19,7 @@ describe ActiveFedora::QueryResultBuilder do
|
|
19
19
|
|
20
20
|
it "returns an array of objects that are of the class stored in active_fedora_model_s" do
|
21
21
|
query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([test_object.id, foo_object.id])
|
22
|
-
solr_result = ActiveFedora::SolrService.query(query)
|
22
|
+
solr_result = ActiveFedora::SolrService.query(query, rows: 10)
|
23
23
|
result = described_class.reify_solr_results(solr_result)
|
24
24
|
expect(result.length).to eq 2
|
25
25
|
result.each do |r|
|
@@ -29,7 +29,7 @@ describe ActiveFedora::QueryResultBuilder do
|
|
29
29
|
|
30
30
|
it '#reifies a lightweight object as a new instance' do
|
31
31
|
query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([foo_object.id])
|
32
|
-
solr_result = ActiveFedora::SolrService.query(query)
|
32
|
+
solr_result = ActiveFedora::SolrService.query(query, rows: 10)
|
33
33
|
result = described_class.reify_solr_results(solr_result, load_from_solr: true)
|
34
34
|
expect(result.first).to be_instance_of FooObject
|
35
35
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe ActiveFedora::NullLogger do
|
4
|
+
[:debug?, :info?, :warn?, :error?, :fatal?].each do |method_name|
|
5
|
+
describe "##{method_name}" do
|
6
|
+
subject { described_class.new.public_send(method_name) }
|
7
|
+
it { is_expected.to be_falsey }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -62,15 +62,23 @@ describe ActiveFedora::SolrService do
|
|
62
62
|
describe "#query" do
|
63
63
|
let(:doc) { { 'id' => 'x' } }
|
64
64
|
let(:docs) { [doc] }
|
65
|
+
let(:stub_result) { { 'response' => { 'docs' => docs } } }
|
66
|
+
before do
|
67
|
+
allow(described_class).to receive(:instance).and_return(double("instance", conn: mock_conn))
|
68
|
+
end
|
65
69
|
|
66
70
|
it "wraps the solr response documents in Solr hits" do
|
67
|
-
|
68
|
-
|
69
|
-
allow(described_class).to receive(:instance).and_return(double("instance", conn: mock_conn))
|
70
|
-
result = described_class.query('querytext')
|
71
|
+
expect(mock_conn).to receive(:get).with('select', params: { rows: 2, q: 'querytext', qt: 'standard' }).and_return(stub_result)
|
72
|
+
result = described_class.query('querytext', rows: 2)
|
71
73
|
expect(result.size).to eq 1
|
72
74
|
expect(result.first.id).to eq 'x'
|
73
75
|
end
|
76
|
+
|
77
|
+
it "warns about not passing rows" do
|
78
|
+
allow(mock_conn).to receive(:get).and_return(stub_result)
|
79
|
+
expect(ActiveFedora::Base.logger).to receive(:warn).with(/^Calling ActiveFedora::SolrService\.get without passing an explicit value for ':rows' is not recommended/)
|
80
|
+
described_class.query('querytext')
|
81
|
+
end
|
74
82
|
end
|
75
83
|
|
76
84
|
describe ".count" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 11.1.
|
4
|
+
version: 11.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-01-
|
13
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -582,6 +582,7 @@ files:
|
|
582
582
|
- spec/integration/solr_hit_spec.rb
|
583
583
|
- spec/integration/versionable_spec.rb
|
584
584
|
- spec/integration/with_metadata_spec.rb
|
585
|
+
- spec/lib/active_fedora/null_logger_spec.rb
|
585
586
|
- spec/rcov.opts
|
586
587
|
- spec/spec.opts
|
587
588
|
- spec/spec_helper.rb
|