<commit_before>##
# Simplified catalog controller
class CatalogController < ApplicationController
  include Blacklight::Catalog
  self.search_params_logic += [:hide_parented_resources, :join_from_parent]
  before_action :search_across_settings

  def search_across_settings
    return if current_exhibit
    blacklight_config.add_index_field 'readonly_subject_tesim', label: 'Subject'
    blacklight_config.add_index_field 'readonly_description_tesim', label: 'Description'

    blacklight_config.add_facet_field 'readonly_language_ssim', label: 'Language'
    blacklight_config.add_facet_field 'readonly_format_ssim', label: 'Format'
    Spotlight::CustomField.all.group(:field).each do |field|
      blacklight_config.add_show_field field.field, label: field.configuration["label"]
    end
  end

  configure_blacklight do |config|
    config.show.oembed_field = :oembed_url_ssm
    config.show.partials.insert(1, :oembed)
    config.view.gallery.partials = [:index_header, :index]
    config.view.masonry.partials = [:index]
    config.view.slideshow.partials = [:index]

    config.show.tile_source_field = :tile_source_ssim
    config.show.partials.insert(1, :universal_viewer)

    ## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
    config.default_solr_params = {
      qt: 'search',
      rows: 10,
      fl: '*',
      group: true,<commit_msg>Fix unique custom field query for postgres. (#110)<commit_after>##
# Simplified catalog controller
class CatalogController < ApplicationController
  include Blacklight::Catalog
  self.search_params_logic += [:hide_parented_resources, :join_from_parent]
  before_action :search_across_settings

  def search_across_settings
    return if current_exhibit
    blacklight_config.add_index_field 'readonly_subject_tesim', label: 'Subject'
    blacklight_config.add_index_field 'readonly_description_tesim', label: 'Description'

    blacklight_config.add_facet_field 'readonly_language_ssim', label: 'Language'
    blacklight_config.add_facet_field 'readonly_format_ssim', label: 'Format'
    unique_custom_fields.each do |field|
      blacklight_config.add_show_field field.field, label: field.configuration["label"]
    end
  end

  def unique_custom_fields
    Spotlight::CustomField.select(:field, :configuration).distinct
  end

  configure_blacklight do |config|
    config.show.oembed_field = :oembed_url_ssm
    config.show.partials.insert(1, :oembed)
    config.view.gallery.partials = [:index_header, :index]
    config.view.masonry.partials = [:index]
    config.view.slideshow.partials = [:index]

    config.show.tile_source_field = :tile_source_ssim
    config.show.partials.insert(1, :universal_viewer)

    ## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
    config.default_solr_params = {
      qt: 'search',
      rows: 10,
      fl: '*',
      group: true,
{'fraction_non_alphanumeric': 0.09251700680272108, 'fraction_numerical': 0.0037414965986394557, 'mean_word_length': 4.8937875751503, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3852688', 'n_tokens_mistral': 954, 'n_tokens_neox': 914, 'n_words': 177}