<commit_before>
require 'api_entity'

class ApplicationController < ActionController::Base
  protect_from_forgery

  before_filter :initialize_modules
  before_filter :set_cache
  layout :set_layout

  rescue_from Errno::ECONNREFUSED do |e|
    render text: '', status: :error
  end
  rescue_from ApiEntity::NotFound do ||
    render text: '404', status: 404
  end
  rescue_from ApiEntity::Error do |e|
    render text: '', status: :error
  end

  def url_options
    { as_of: @tariff_date }.merge(super)
  end

  private

  def initialize_modules
    @search = Search.new(params)
    @tariff_date = TariffDate.new(params[:as_of])
  end

  def set_layout
    if request.headers['X-PJAX']
      response.headers[Slimmer::SKIP_HEADER] = "true"
      "pjax"
    elsif request.headers['X-AJAX']
      response.headers[Slimmer::SKIP_HEADER] = "true"
      false
    else
      "application"
    end
  end

  def query_params
    { query: { as_of: @tariff_date } }
  end

  def set_cache
    expires_in 2.hours, :public => true, 'max-stale' => 0
  end
end
<commit_msg>whitespace<commit_after>require 'api_entity'

class ApplicationController < ActionController::Base
  protect_from_forgery

  before_filter :initialize_modules
  before_filter :set_cache
  layout :set_layout

  rescue_from Errno::ECONNREFUSED do |e|
    render text: '', status: :error
  end
  rescue_from ApiEntity::NotFound do ||
    render text: '404', status: 404
  end
  rescue_from ApiEntity::Error do |e|
    render text: '', status: :error
  end

  def url_options
    { as_of: @tariff_date }.merge(super)
  end

  private

  def initialize_modules
    @search = Search.new(params)
    @tariff_date = TariffDate.new(params[:as_of])
  end

  def set_layout
    if request.headers['X-PJAX']
      response.headers[Slimmer::SKIP_HEADER] = "true"
      "pjax"
    elsif request.headers['X-AJAX']
      response.headers[Slimmer::SKIP_HEADER] = "true"
      false
    else
      "application"
    end
  end

  def query_params
    { query: { as_of: @tariff_date } }
  end

  def set_cache
    expires_in 2.hours, :public => true, 'max-stale' => 0
  end
end

{'fraction_non_alphanumeric': 0.10377358490566038, 'fraction_numerical': 0.007547169811320755, 'mean_word_length': 3.400414937759336, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1446431', 'n_tokens_mistral': 762, 'n_tokens_neox': 737, 'n_words': 171}