<commit_before>require 'api_entity'
class ApplicationController < ActionController::Base
  protect_from_forgery

  before_filter :initialize_modules

  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
    { date: @tariff_date }.merge(super)
  end

  private

  def initialize_modules
    @search = Search.new(params)
    @tariff_date = TariffDate.new(params[:date])
  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
end
<commit_msg>cache everything and hope varnish will save us<commit_after>require 'api_entity'
class ApplicationController < ActionController::Base
  protect_from_forgery

  before_filter :initialize_modules
  before_filter :cache_all_the_things

  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
    { date: @tariff_date }.merge(super)
  end

  private

  def initialize_modules
    @search = Search.new(params)
    @tariff_date = TariffDate.new(params[:date])
  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 cache_all_the_things
    expires_in 6.hours, :public => true, 'max-stale' => 0
  end
end

{'fraction_non_alphanumeric': 0.10025839793281653, 'fraction_numerical': 0.007235142118863049, 'mean_word_length': 3.5660377358490565, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1446440', 'n_tokens_mistral': 671, 'n_tokens_neox': 648, 'n_words': 154}