-
Notifications
You must be signed in to change notification settings - Fork 124
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
deprecate FindObjectsViaSolrService replaced by SolrQueryService#get_objects #5023
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,9 +55,12 @@ def single_membership_collections(collection_ids) | |
|
||
field_pairs = { | ||
:id => collection_ids, | ||
Hyrax.config.collection_type_index_field.to_sym => collection_type_gids_that_disallow_multiple_membership | ||
Hyrax.config.collection_type_index_field.to_sym => collection_type_gids_that_disallow_multiple_membership&.map(&:to_s) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The map to strings is required to turn GlobalIDs into string IDs. I'm not sure why this worked before. It definitely does not work with the SolrQueryService. |
||
} | ||
Hyrax::FindObjectsViaSolrService.find_for_model_by_field_pairs(model: ::Collection, field_pairs: field_pairs, use_valkyrie: true) | ||
Hyrax::SolrQueryService.new | ||
.with_model(model: ::Collection) | ||
.with_field_pairs(field_pairs: field_pairs, join_with: ' OR ') | ||
.get_objects(use_valkyrie: true).to_a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The result is required to be an Array because later it is used in...
where the result is |
||
end | ||
|
||
def collection_type_gids_that_disallow_multiple_membership | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ module Hyrax | |
# Methods in this class are providing functionality previously supported by ActiveFedora::SolrQueryBuilder. | ||
# It includes methods to build and execute a query. | ||
class SolrQueryService | ||
class_attribute :query_service | ||
self.query_service = Hyrax.query_service | ||
|
||
attr_reader :query, :solr_service | ||
|
||
def initialize(query: [], solr_service: Hyrax::SolrService) | ||
|
@@ -17,6 +20,21 @@ def get | |
solr_service.get(build) | ||
end | ||
|
||
## | ||
# @return [Array<String>] ids of documents matching the current query | ||
def get_ids # rubocop:disable Naming/AccessorMethodName | ||
results = get | ||
results['response']['docs'].map { |doc| doc['id'] } | ||
end | ||
|
||
## | ||
# @return [Array<Valkyrie::Resource|ActiveFedora::Base>] objects matching the current query | ||
def get_objects(use_valkyrie: Hyrax.config.use_valkyrie?) | ||
ids = get_ids | ||
return ids.map { |id| ActiveFedora::Base.find(id) } unless use_valkyrie | ||
query_service.find_many_by_ids(ids: ids) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
end | ||
|
||
## | ||
# @return [Integer] the number of results that match the query in solr | ||
def count | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FindObjectViaSolrService #find_for_model_by_field_pairs needs to continue to return an Array for backward compatibility.
This method is no longer used in any Hyrax code.