From c591dee92f68930af8b426eeb6524b7543a8b16f Mon Sep 17 00:00:00 2001 From: Harpo Harbert Date: Fri, 19 Apr 2024 10:24:02 -0700 Subject: [PATCH] Adds solr_url env config --- app/controllers/oai_controller.rb | 2 +- app/models/pb_core_presenter.rb | 2 +- config/environments/development.rb | 3 +++ config/environments/production.rb | 3 +++ config/environments/test.rb | 3 +++ scripts/lib/downloader.rb | 2 +- spec/solr/analysis_spec.rb | 2 +- 7 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/controllers/oai_controller.rb b/app/controllers/oai_controller.rb index 19544073e5..4e210b929a 100644 --- a/app/controllers/oai_controller.rb +++ b/app/controllers/oai_controller.rb @@ -19,7 +19,7 @@ def index @response_date = Time.now.strftime('%FT%T') @records = - RSolr.connect(url: 'http://localhost:8983/solr/') + RSolr.connect(url: config.solr_url) .get('select', params: { 'q' => 'access_types:"' + PBCorePresenter::PUBLIC_ACCESS + '"', 'fl' => 'id,timestamp,xml', diff --git a/app/models/pb_core_presenter.rb b/app/models/pb_core_presenter.rb index 2a0b88a3ea..88f2620e8d 100644 --- a/app/models/pb_core_presenter.rb +++ b/app/models/pb_core_presenter.rb @@ -419,7 +419,7 @@ def playlist_order end def playlist_map @playlist_map ||= begin - response = RSolr.connect(url: 'http://localhost:8983/solr/').get('select', params: + response = RSolr.connect(url: config.solr_url).get('select', params: { 'fl' => 'playlist_order,id', 'fq' => "playlist_group:#{playlist_group}", diff --git a/config/environments/development.rb b/config/environments/development.rb index 9e565cc91b..3b4728bf54 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,6 +1,9 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + # Solr URL + config.solr_url = ENV['SOLR_URL'] || 'http://localhost:8983/solr' + # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. diff --git a/config/environments/production.rb b/config/environments/production.rb index b892695009..870229ebc8 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,6 +1,9 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + # Solr URL + config.solr_url = ENV['SOLR_URL'] || 'http://localhost:8983/solr' + # Code is not reloaded between requests. config.cache_classes = true diff --git a/config/environments/test.rb b/config/environments/test.rb index a561ca6755..ddd76a38fb 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,6 +1,9 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + # Solr URL + config.solr_url = ENV['SOLR_URL'] || 'http://localhost:8983/solr' + # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped diff --git a/scripts/lib/downloader.rb b/scripts/lib/downloader.rb index cba51e84bf..b17196d516 100644 --- a/scripts/lib/downloader.rb +++ b/scripts/lib/downloader.rb @@ -112,7 +112,7 @@ def process_query(query) q = QueryMaker.translate(query) $LOG.info("Query solr for #{query}") - @options[:ids] = RSolr.connect(url: 'http://localhost:8983/solr/') + @options[:ids] = RSolr.connect(url: config.solr_url) .get('select', params: { q: q, fl: 'id', rows: MAX_ROWS } )['response']['docs'].map { |doc| doc['id'] } diff --git a/spec/solr/analysis_spec.rb b/spec/solr/analysis_spec.rb index 71a04f1c51..1250a3800e 100644 --- a/spec/solr/analysis_spec.rb +++ b/spec/solr/analysis_spec.rb @@ -10,7 +10,7 @@ def analyze(input) 'analysis.fieldvalue' => input, 'analysis.fieldtype' => 'sort' ) - json = URI('http://localhost:8983/solr/blacklight-core/analysis/field?' + params).read + json = URI(config.solr_url + '/blacklight-core/analysis/field?' + params).read JSON.parse(json)['analysis']['field_types']['sort']['index'].last.last['text'] end it 'folds diacritics' do