<commit_before>require_relative "config/environment"
require_relative "authentication"

class SassHandler < Sinatra::Base   
  set :views, File.dirname(__FILE__) + '/app/assets/stylesheets'
    
  get '/css/*.css' do
    filename = params[:splat].first
    sass filename.to_sym
  end    
end

class DatashareFilter < Sinatra::Base
  BOROUGH_CODES_TO_NAMES = {"M" => "Manhattan", "S" => "Staten Island", "K" => "Brooklyn", "B" => "Bronx", "Q" => "Queens"}
  BOROUGH_CODES = %w(M S K B Q)

  register Sinatra::Twitter::Bootstrap::Assets
  register WillPaginate::Sinatra
  use SassHandler

  WillPaginate.per_page = 15

  if ENV["RACK_ENV"] != "development"
    use Authentication, "Protected Area", ['/api/status'] do |username, password|
      username == ENV["CCS_USERNAME"] && password == ENV["CCS_PASSWORD"]
    end
  end

  configure do
    set :views, settings.root + '/app/views'
    set :haml, :format => :html5
  end

  get '/' do
    puts params.inspect
    params[:filter] = {} unless params[:filter]
    
    @incidents = IncidentFilter.scope(params[:filter])

    if params[:format] == "csv"
      response.headers["Content-Type"]        = "text/csv; charset=UTF-8; header=present"
      response.headers["Content-Disposition"] = "attachment; filename=cases.csv"
      erb :export_csv
    else
      @incidents = @incidents.paginate(:page => params[:page])
      haml :index
    end
  end

  get '/api/status' do
    status = "ok"
    begin
      Incident.first
    rescue
      status = "down"
    end

    {
      status: status,
      updated: Time.now.to_i,
      dependencies: [],
      resources: {}
    }.to_json
  end

  helpers ApplicationHelper
end
<commit_msg>Change endpoint of status check. #141<commit_after>require_relative "config/environment"
require_relative "authentication"

class SassHandler < Sinatra::Base   
  set :views, File.dirname(__FILE__) + '/app/assets/stylesheets'
    
  get '/css/*.css' do
    filename = params[:splat].first
    sass filename.to_sym
  end    
end

class DatashareFilter < Sinatra::Base
  BOROUGH_CODES_TO_NAMES = {"M" => "Manhattan", "S" => "Staten Island", "K" => "Brooklyn", "B" => "Bronx", "Q" => "Queens"}
  BOROUGH_CODES = %w(M S K B Q)

  register Sinatra::Twitter::Bootstrap::Assets
  register WillPaginate::Sinatra
  use SassHandler

  WillPaginate.per_page = 15

  if ENV["RACK_ENV"] != "development"
    use Authentication, "Protected Area", ['/.well-known/status'] do |username, password|
      username == ENV["CCS_USERNAME"] && password == ENV["<PASSWORD>"]
    end
  end

  configure do
    set :views, settings.root + '/app/views'
    set :haml, :format => :html5
  end

  get '/' do
    puts params.inspect
    params[:filter] = {} unless params[:filter]
    
    @incidents = IncidentFilter.scope(params[:filter])

    if params[:format] == "csv"
      response.headers["Content-Type"]        = "text/csv; charset=UTF-8; header=present"
      response.headers["Content-Disposition"] = "attachment; filename=cases.csv"
      erb :export_csv
    else
      @incidents = @incidents.paginate(:page => params[:page])
      haml :index
    end
  end

  get '/.well-known/status' do
    status = "ok"
    begin
      Incident.first
    rescue
      status = "down"
    end

    {
      status: status,
      updated: Time.now.to_i,
      dependencies: [],
      resources: {}
    }.to_json
  end

  helpers ApplicationHelper
end

{'fraction_non_alphanumeric': 0.13932980599647266, 'fraction_numerical': 0.003233392122281011, 'mean_word_length': 3.1148730350665055, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 18, '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': '1312971', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1133, 'n_words': 261}