<commit_before># encoding: UTF-8

require 'sinatra'
require 'slim'
require 'json'
require 'yaml'
require 'securerandom'
require 'redis'
require 'digest/sha1'
require 'set'
require 'statsample'
require 'csv'

require_relative 'lib/survey_answer.rb'
require_relative 'lib/word_processor.rb'

configure do
  enable :sessions
  set :protection, :except => [:frame_options, :ip_spoofing]
  raise 'Session secret key not fond. Run `rake session.secret` to generate one.' \
    unless File.exists?('session.secret')
  set :session_secret, File.read('session.secret')
  set :password_hash, File.read('password.<PASSWORD>')
  set :db, Redis.new(YAML.load_file('db.yml'))
  set :figures_path, File.join('upload', 'figures')
end

configure :development do
  Slim::Engine.default_options[:pretty] = true
end

configure :test do
  disable :logging
end

helpers do
  def badge_for_frequency(frequency)
    case frequency
    when 1
      ''
    when 2..10<commit_msg>Extended session expiration to one month<commit_after># encoding: UTF-8

require 'sinatra'
require 'slim'
require 'json'
require 'yaml'
require 'securerandom'
require 'redis'
require 'digest/sha1'
require 'set'
require 'statsample'
require 'csv'

require_relative 'lib/survey_answer.rb'
require_relative 'lib/word_processor.rb'

configure do
  use Rack::Session::Cookie, :expire_after => 60*60*24*30, #30 days in seconds
                             :secret => File.read('session.secret')
  set :protection, :except => [:frame_options, :ip_spoofing]
  raise 'Session secret key not fond. Run `rake session.secret` to generate one.' \
    unless File.exists?('session.secret')
  set :password_hash, File.read('password.secret')
  set :db, Redis.new(YAML.load_file('db.yml'))
  set :figures_path, File.join('upload', 'figures')
end

configure :development do
  Slim::Engine.default_options[:pretty] = true
end

configure :test do
  disable :logging
end

helpers do
  def badge_for_frequency(frequency)
    case frequency
    when 1
      ''
    when 2..10
{'fraction_non_alphanumeric': 0.12113659022931206, 'fraction_numerical': 0.010967098703888335, 'mean_word_length': 4.575, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, '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': '1471261', 'n_tokens_mistral': 685, 'n_tokens_neox': 648, 'n_words': 181}