Skip to content

Commit

Permalink
clean up from pr review
Browse files Browse the repository at this point in the history
  • Loading branch information
orangewolf committed Dec 20, 2023
1 parent 95a2228 commit a32c814
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 22 deletions.
3 changes: 1 addition & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ FCREPO_BASE_PATH=/hykudemo
FCREPO_HOST=fcrepo
FCREPO_PORT=8080
FCREPO_REST_PATH=rest
HYRAX_ACTIVE_JOB_QUEUE=good_job
HYRAX_ACTIVE_JOB_QUEUE=sidekiq
HYRAX_FITS_PATH=/app/fits/fits.sh
INITIAL_ADMIN_EMAIL=[email protected]
INITIAL_ADMIN_PASSWORD=testing123
IN_DOCKER=true
JAVA_OPTS=
JAVA_OPTS=-Xmx4g -Xms1g
LD_LIBRARY_PATH=/opt/fits/tools/mediainfo/linux
NEGATIVE_CAPTCHA_SECRET=default-value-change-me
Expand Down
21 changes: 1 addition & 20 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def self.uploaded_field
config.search_builder_class = IiifPrint::CatalogSearchBuilder

# Use locally customized AdvSearchBuilder so we can enable blacklight_advanced_search
# TODO ROB config.search_builder_class = AdvSearchBuilder
config.search_builder_class = AdvSearchBuilder

# Show gallery view
config.view.gallery.partials = %i[index_header index]
Expand Down Expand Up @@ -122,22 +122,6 @@ def self.uploaded_field
# handler defaults, or have no facets.
config.add_facet_fields_to_solr_request!

# TODO: ROB
# # Prior to this change, the applications specific translations were not loaded. Dogbiscuits were assuming the translations were already loaded.
# Rails.root.glob("config/locales/*.yml").each do |path|
# I18n.load_path << path.to_s
# end
# I18n.backend.reload!
# index_props = DogBiscuits.config.index_properties.collect do |prop|
# { prop => index_options(prop, DogBiscuits.config.property_mappings[prop]) }
# end
# add_index_field config, index_props

# solr fields to be displayed in the show (single result) view
# The ordering of the field names is the order of the display
# show_props = DogBiscuits.config.all_properties
# add_show_field config, show_props

# solr fields to be displayed in the index (search results) view
# The ordering of the field names is the order of the display
config.add_index_field 'title_tesim', label: "Title", itemprop: 'name', if: false
Expand Down Expand Up @@ -202,8 +186,6 @@ def self.uploaded_field
# since we aren't specifying it otherwise.
config.add_search_field('all_fields', label: 'All Fields', include_in_advanced_search: false) do |field|
all_names = config.show_fields.values.map(&:field).join(" ")
# TODO: ROB all_names = (config.show_fields.values.map { |v| v.field.to_s } +
# DogBiscuits.config.all_properties.map { |p| "#{p}_tesim" }).uniq.join(" ")
title_name = 'title_tesim'
field.solr_parameters = {
qf: "#{all_names} file_format_tesim all_text_timv",
Expand Down Expand Up @@ -232,7 +214,6 @@ def self.uploaded_field
end

config.add_search_field('creator') do |field|
# TODO: ROB field.label = "Author"
field.solr_parameters = { "spellcheck.dictionary": "creator" }
solr_name = 'creator_tesim'
field.solr_local_parameters = {
Expand Down
26 changes: 26 additions & 0 deletions app/search_builders/adv_search_builder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

class AdvSearchBuilder < IiifPrint::CatalogSearchBuilder
include Blacklight::Solr::SearchBuilderBehavior
include BlacklightAdvancedSearch::AdvancedSearchBuilder

# A Solr param filter that is NOT included by default in the chain,
# but is appended by AdvancedController#index, to do a search
# for facets _ignoring_ the current query, we want the facets
# as if the current query weren't there.
#
# Also adds any solr params set in blacklight_config.advanced_search[:form_solr_parameters]
def facets_for_advanced_search_form(solr_p)
# ensure empty query is all records, to fetch available facets on entire corpus
solr_p["q"] = '{!lucene}*:*'
# explicitly use lucene defType since we are passing a lucene query above (and appears to be required for solr 7)
solr_p["defType"] = 'lucene'
# We only care about facets, we don't need any rows.
solr_p["rows"] = "0"

# Anything set in config as a literal
if blacklight_config.advanced_search[:form_solr_parameters]
solr_p.merge!(blacklight_config.advanced_search[:form_solr_parameters])
end
end
end
57 changes: 57 additions & 0 deletions spec/search_builders/adv_search_builder_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# frozen_string_literal: true

RSpec.describe AdvSearchBuilder do
let(:scope) do
double(blacklight_config: CatalogController.blacklight_config,
current_ability: ability)
end
let(:user) { create(:user) }
let(:ability) { ::Ability.new(user) }
let(:access) { :read }
let(:builder) { described_class.new(scope).with_access(access) }

it "can be instantiated" do
expect(builder).to be_instance_of(described_class)
end

describe ".default_processor_chain" do
subject { described_class.default_processor_chain }

let(:expected_default_processor_chain) do
# Yes there's a duplicate for add_access_controls_to_solr_params; but that does not appear to
# be causing a problem like the duplication and order of the now removed additional
# :add_advanced_parse_q_to_solr, :add_advanced_search_to_solr filters. Those existed in their
# current position and at the end of the array.
#
# When we had those duplicates, the :add_advanced_parse_q_to_solr obliterated the join logic
# for files.
%i[
default_solr_parameters
add_query_to_solr
add_facet_fq_to_solr
add_facetting_to_solr
add_solr_fields_to_query
add_paging_to_solr
add_sorting_to_solr
add_group_config_to_solr
add_facet_paging_to_solr
add_range_limit_params
add_advanced_parse_q_to_solr
add_advanced_search_to_solr
add_access_controls_to_solr_params
filter_models
only_active_works
add_access_controls_to_solr_params
show_works_or_works_that_contain_files
show_only_active_records
filter_collection_facet_for_access
exclude_models
highlight_search_params
show_parents_only
include_allinson_flex_fields
]
end

it { is_expected.to eq(expected_default_processor_chain) }
end
end

0 comments on commit a32c814

Please sign in to comment.