Skip to content

Commit

Permalink
🐛 Favor Hyrax::SolrService where possible
Browse files Browse the repository at this point in the history
We need one remaining `ActiveFedora::SolrService` reference to tie into
that not yet removed class.
  • Loading branch information
jeremyf committed Jan 31, 2024
1 parent 206cb5f commit 63ff817
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def show
def accessible_works
models = Hyrax.config.curation_concerns.map { |m| "\"#{m}\"" }
if current_user.ability.admin?
ActiveFedora::SolrService.query("has_model_ssim:(#{models.join(' OR ')})",
Hyrax::SolrService.query("has_model_ssim:(#{models.join(' OR ')})",
fl: 'title_tesim, id, member_of_collections',
rows: 50_000)
else
ActiveFedora::SolrService.query(
Hyrax::SolrService.query(
"edit_access_person_ssim:#{current_user} AND has_model_ssim:(#{models.join(' OR ')})",
fl: 'title_tesim, id, member_of_collections',
rows: 50_000
Expand All @@ -55,13 +55,13 @@ def accessible_works

def accessible_file_sets
if current_user.ability.admin?
ActiveFedora::SolrService.query(
Hyrax::SolrService.query(
"has_model_ssim:FileSet",
fl: 'title_tesim, id',
rows: 50_000
)
else
ActiveFedora::SolrService.query(
Hyrax::SolrService.query(
"edit_access_person_ssim:#{current_user} AND has_model_ssim:FileSet",
fl: 'title_tesim, id',
rows: 50_000
Expand Down
2 changes: 1 addition & 1 deletion app/models/hyrax/statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def ga_statistics(start_date, object)

def query_works(query)
models = Hyrax.config.curation_concerns.map { |m| "\"#{m}\"" }
ActiveFedora::SolrService.query("has_model_ssim:(#{models.join(' OR ')})", fl: query, rows: 100_000)
Hyrax::SolrService.query("has_model_ssim:(#{models.join(' OR ')})", fl: query, rows: 100_000)
end

def work_types
Expand Down
2 changes: 1 addition & 1 deletion app/services/hyrax/solr_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SolrService
delegate :commit, to: :connection

def initialize(use_valkyrie: Hyrax.config.query_index_from_valkyrie)
@old_service = ActiveFedora::SolrService
@old_service = ActiveFedora::SolrService # What hopefully will be the lone reference to ActiveFedora::SolrService
@use_valkyrie = use_valkyrie
end

Expand Down
4 changes: 2 additions & 2 deletions lib/wings/services/custom_queries/find_ids_by_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def find_ids_by_model(model:, ids: :all)
model_name = ModelRegistry.lookup(model).model_name

solr_query = "_query_:\"{!raw f=has_model_ssim}#{model_name}\""
solr_response = ActiveFedora::SolrService.get(solr_query, fl: 'id', rows: @query_rows)['response']
solr_response = Hyrax::SolrService.get(solr_query, fl: 'id', rows: @query_rows)['response']

loop do
response_docs = solr_response['docs']
Expand All @@ -38,7 +38,7 @@ def find_ids_by_model(model:, ids: :all)
response_docs.each { |doc| yield doc['id'] }

break if (solr_response['start'] + solr_response['docs'].count) >= solr_response['numFound']
solr_response = ActiveFedora::SolrService.get(solr_query, fl: 'id', rows: @query_rows, start: solr_response['start'] + @query_rows)['response']
solr_response = Hyrax::SolrService.get(solr_query, fl: 'id', rows: @query_rows, start: solr_response['start'] + @query_rows)['response']
end
end
end
Expand Down

0 comments on commit 63ff817

Please sign in to comment.