<commit_before>require "sinatra/base"
require "sinatra/reloader"
require "sinatra-initializers"
require "sinatra/r18n"

module OpenCity
  class Application < Sinatra::Base
    enable :logging, :sessions
    enable :dump_errors, :show_exceptions if development?

    configure :development do
      register Sinatra::Reloader
    end

    register Sinatra::Initializers
    register Sinatra::R18n

    before do
      session[:locale] = params[:locale] if params[:locale]
    end

    use Rack::Logger
    use Rack::Session::Cookie

    helpers OpenCity::HtmlHelpers

    get "/" do
      cache_control :public, max_age: 3600  # 1 hour
      haml :index
    end

    # utility for flushing cache
    get "/flush_cache" do
      if memcache_servers = ENV["MEMCACHE_SERVERS"]
        require 'dalli'
        dc = Dalli::Client.new
        dc.flush
      end
      redirect "/"
    end
  end
end
<commit_msg>logic fix for cache flush<commit_after>require "sinatra/base"
require "sinatra/reloader"
require "sinatra-initializers"
require "sinatra/r18n"

module OpenCity
  class Application < Sinatra::Base
    enable :logging, :sessions
    enable :dump_errors, :show_exceptions if development?

    configure :development do
      register Sinatra::Reloader
    end

    register Sinatra::Initializers
    register Sinatra::R18n

    before do
      session[:locale] = params[:locale] if params[:locale]
    end

    use Rack::Logger
    use Rack::Session::Cookie

    helpers OpenCity::HtmlHelpers

    get "/" do
      cache_control :public, max_age: 3600  # 1 hour
      haml :index
    end

    # utility for flushing cache
    get "/flush_cache" do
      unless ENV["MEMCACHE_SERVERS"].nil? or ENV["MEMCACHE_SERVERS"] == ''
        require 'dalli'
        dc = Dalli::Client.new
        dc.flush
      end
      redirect "/"
    end
  end
end

{'fraction_non_alphanumeric': 0.08844275637547477, 'fraction_numerical': 0.009766684753119913, 'mean_word_length': 2.8577405857740588, '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': '6484160', 'n_tokens_mistral': 592, 'n_tokens_neox': 558, 'n_words': 155}