Class: Spotlight::BlacklightConfigurationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Spotlight::BlacklightConfigurationsController
- Includes:
- Blacklight::SolrHelper
- Defined in:
- app/controllers/spotlight/blacklight_configurations_controller.rb
Instance Method Summary collapse
-
#alternate_count ⇒ Object
the luke request handler can return document counts, but the seem to be incorrect.
- #available_configurations ⇒ Object
-
#edit_facet_fields ⇒ Object
Edit the index and show view metadata fields.
-
#edit_metadata_fields ⇒ Object
Edit the index and show view metadata fields.
- #metadata_fields ⇒ Object
- #update ⇒ Object
Methods included from Controller
#blacklight_config, #current_exhibit, #exhibit_search_action_url, #exhibit_search_facet_url, #search_action_url, #search_facet_url
Methods included from Config
#exhibit_specific_blacklight_config
Instance Method Details
#alternate_count ⇒ Object
the luke request handler can return document counts, but the seem to be incorrect. They seem to be for the whole index and they decrease after optimizing. This method finds those counts by doing regular facet queries
54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/spotlight/blacklight_configurations_controller.rb', line 54 def alternate_count @alt_count ||= begin facet_query = @blacklight_configuration.blacklight_config.facet_fields.keys.map { |key| "#{key}:[* TO *]" } solr_resp = solr_repository.search('facet.query' => facet_query, 'rows' =>0, 'facet' => true) @alt_count = solr_resp['facet_counts']['facet_queries'].each_with_object({}) do |(key, val), alt_count| alt_count[key.split(/:/).first] = val end end end |
#available_configurations ⇒ Object
28 29 30 31 32 |
# File 'app/controllers/spotlight/blacklight_configurations_controller.rb', line 28 def available_configurations respond_to do |format| format.json { render json: @blacklight_configuration.default_blacklight_config } end end |
#edit_facet_fields ⇒ Object
Edit the index and show view metadata fields
44 45 46 47 48 49 |
# File 'app/controllers/spotlight/blacklight_configurations_controller.rb', line 44 def edit_facet_fields t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit) t(:'spotlight.curation.sidebar.search_facets'), exhibit_edit_facets_path(@exhibit) @fields = solr_repository.send_and_receive('admin/luke', fl: '*', 'json.nl' => 'map')['fields'] end |
#edit_metadata_fields ⇒ Object
Edit the index and show view metadata fields
36 37 38 39 40 |
# File 'app/controllers/spotlight/blacklight_configurations_controller.rb', line 36 def t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit) t(:'spotlight.curation.sidebar.metadata'), (@exhibit) end |
#metadata_fields ⇒ Object
22 23 24 25 26 |
# File 'app/controllers/spotlight/blacklight_configurations_controller.rb', line 22 def respond_to do |format| format.json { render json: @blacklight_configuration.blacklight_config.index_fields.as_json } end end |
#update ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/spotlight/blacklight_configurations_controller.rb', line 8 def update if @blacklight_configuration.update(exhibit_params) flash[:notice] = t(:'helpers.submit.blacklight_configuration.updated', model: @blacklight_configuration.class.model_name.human.downcase) end if params[:blacklight_configuration][:index_fields] redirect_to (@exhibit) elsif params[:blacklight_configuration][:facet_fields] redirect_to exhibit_edit_facets_path(@exhibit) else redirect_to exhibit_dashboard_path(@exhibit) end end |