Skip to content

Commit

Permalink
Allow Solr URL in SystemStats module to be overridden
Browse files Browse the repository at this point in the history
  • Loading branch information
mjgiarlo committed May 17, 2016
1 parent 64238e6 commit c8afeb5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/services/sufia/system_stats.rb
Expand Up @@ -98,8 +98,12 @@ def query_service
@query_service ||= Sufia::QueryService.new
end

def terms_component_base_path
"#{ActiveFedora.solr_config[:url]}/terms"

This comment has been minimized.

Copy link
@cbeer

cbeer May 17, 2016

Contributor

I suggest we should dig into ActiveFedora::SolrService.instance, instead of grabbing the configuration directly.

This comment has been minimized.

Copy link
@cbeer

cbeer May 17, 2016

Contributor

Or.. can we use the ActiveFedora::SolrService.instance.conn to actually make this query? open-uri makes me nervous in general.

end

def top_data(key, limit)
query_url = "#{ActiveFedora.solr_config[:url]}/terms?terms.fl=#{key}&terms.sort=count&terms.limit=#{limit}&wt=json&omitHeader=true"
query_url = "#{terms_component_base_path}?terms.fl=#{key}&terms.sort=count&terms.limit=#{limit}&wt=json&omitHeader=true"
# Parse JSON response (looks like {"terms":{"depositor_tesim":["mjg36",3]}} for depositor)
json = open(query_url).read
unless json
Expand Down

0 comments on commit c8afeb5

Please sign in to comment.