Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 1219 #1230

Merged
merged 8 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/active_fedora/indexing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def index_config
# @param [Boolean] progress_bar - If true output progress bar information. Default false.
# @param [Boolean] final_commit - If true perform a hard commit to the Solr service at the completion of the batch of updates. Default false.
def reindex_everything(batch_size: 50, softCommit: true, progress_bar: false, final_commit: false)
descendants = descendant_uris(ActiveFedora.fedora.base_uri)
descendants.shift # Discard the root uri
# skip root url
descendants = descendant_uris(ActiveFedora.fedora.base_uri, exclude_uri: true)

batch = []

Expand Down Expand Up @@ -119,8 +119,8 @@ def reindex_everything(batch_size: 50, softCommit: true, progress_bar: false, fi
end
end

def descendant_uris(uri)
DescendantFetcher.new(uri).descendant_and_self_uris
def descendant_uris(uri, exclude_uri: false)
DescendantFetcher.new(uri, exclude_self: exclude_uri).descendant_and_self_uris
end
end
end
Expand Down
7 changes: 4 additions & 3 deletions lib/active_fedora/indexing/descendant_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ class DescendantFetcher
HAS_MODEL_PREDICATE = ActiveFedora::RDF::Fcrepo::Model.hasModel

class_attribute :default_priority_models, instance_accessor: false
self.default_priority_models = %w(Hydra::AccessControls Hydra::AccessControls::Permissions).freeze
self.default_priority_models = %w(Hydra::AccessControl Hydra::AccessControl::Permissions).freeze

attr_reader :uri, :priority_models

def initialize(uri,
priority_models: self.class.default_priority_models)
priority_models: self.class.default_priority_models, exclude_self: false)
@uri = uri
@priority_models = priority_models
@exclude_self = exclude_self
end

def descendant_and_self_uris
Expand All @@ -46,7 +47,7 @@ def descendant_and_self_uris_partitioned
# but this causes more requests to Fedora.
return partitioned_uris unless resource.head.rdf_source?

add_self_to_partitioned_uris
add_self_to_partitioned_uris unless @exclude_self

immediate_descendant_uris = rdf_graph.query(predicate: ::RDF::Vocab::LDP.contains).map { |descendant| descendant.object.to_s }
immediate_descendant_uris.each do |descendant_uri|
Expand Down