<commit_before>require_relative "env"
require 'active_support/core_ext/hash/keys'
require_relative 'exception_mailer'

def config_for(kind)
  YAML.load_file(File.expand_path("../#{kind}.yml", __FILE__))
end

def backend_config
  # Note that we're not recursively symbolising keys, because the config for
  # each backend is currently flat. We may need to revisit this.
  config_for(:backends)[ENV["RACK_ENV"]].symbolize_keys
end

set :backends, backend_config
set :elasticsearch_schema, config_for("elasticsearch_schema")

panopticon_api_credentials = config_for(:panopticon_api_credentials)[ENV["RACK_ENV"]]
panopticon_api_credentials.symbolize_keys!

panopticon_api_credentials.values.each do |auth_value|
  # Basic auth is a hash, in which case we symbolize the keys
  # Bearer tokens are a string, in which case we don't
  auth_value.symbolize_keys! if auth_value.respond_to? :symbolize_keys!
end

set :panopticon_api_credentials, panopticon_api_credentials

set :top_results, 4
set :max_more_results, 46
set :max_recommended_results, 2

set :recommended_format, "recommended-link"
set :inside_government_link, "inside-government-link"

set :format_order, ['transaction', 'answer', 'programme', 'guide']

configure :development do
  set :protection, false
end

configure :production do
  if File.exist?("aws_secrets.yml")
    disable :show_exceptions
    use ExceptionMailer, YAML.load_file("aws_secrets.yml"),
        to: ['<EMAIL>', '<EMAIL>'],
        from: '"<NAME>" <<EMAIL>>'
  end
end<commit_msg>Remove GFR from the exception mailer configuration<commit_after>require_relative "env"
require 'active_support/core_ext/hash/keys'
require_relative 'exception_mailer'

def config_for(kind)
  YAML.load_file(File.expand_path("../#{kind}.yml", __FILE__))
end

def backend_config
  # Note that we're not recursively symbolising keys, because the config for
  # each backend is currently flat. We may need to revisit this.
  config_for(:backends)[ENV["RACK_ENV"]].symbolize_keys
end

set :backends, backend_config
set :elasticsearch_schema, config_for("elasticsearch_schema")

panopticon_api_credentials = config_for(:panopticon_api_credentials)[ENV["RACK_ENV"]]
panopticon_api_credentials.symbolize_keys!

panopticon_api_credentials.values.each do |auth_value|
  # Basic auth is a hash, in which case we symbolize the keys
  # Bearer tokens are a string, in which case we don't
  auth_value.symbolize_keys! if auth_value.respond_to? :symbolize_keys!
end

set :panopticon_api_credentials, panopticon_api_credentials

set :top_results, 4
set :max_more_results, 46
set :max_recommended_results, 2

set :recommended_format, "recommended-link"
set :inside_government_link, "inside-government-link"

set :format_order, ['transaction', 'answer', 'programme', 'guide']

configure :development do
  set :protection, false
end

configure :production do
  if File.exist?("aws_secrets.yml")
    disable :show_exceptions
    use ExceptionMailer, YAML.load_file("aws_secrets.yml"),
        to: ['<EMAIL>'],
        from: '"<NAME>" <<EMAIL>>'
  end
end
{'fraction_non_alphanumeric': 0.10296052631578947, 'fraction_numerical': 0.002631578947368421, 'mean_word_length': 6.206161137440758, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '278880', 'n_tokens_mistral': 1035, 'n_tokens_neox': 993, 'n_words': 254}