<commit_before>require 'rubygems'
require 'sinatra/base'
require 'sinatra/content_for'
require 'active_record'

ActiveRecord::Base.establish_connection(
  :adapter  => 'sqlite3',
  :database =>  'data/people.sqlite3.db'
)

connection_handle = ActiveRecord::Base.connection

class People < ActiveRecord::Base
  self.table_name = "people"
end

class Group < ActiveRecord::Base
  def url
    underscore_name = name.downcase.gsub(" ", "-")
    "/group/#{id}-#{underscore_name}"
  end
end

class GuessWho < Sinatra::Base
  helpers Sinatra::ContentFor

  helpers do
    def title
      sub = @group_name
      title = "Guess Who?"
      unless sub.nil?
        title += " | #{sub}"
      end
      return title
    end
  end

  # base route
  get '/' do
    @all_label = ENV["ALL_LABEL"] || "Everyone"
    @groups = Group.all
    erb :home
  end

  get '/group/:group' do
    @group_id = params[:group].split("-")[0]
    @api_end_point = "/#{@group_id}/random.json"
    @use_original_thumbnail = !!(ENV["ORINGAL_THUMBNAIL"] =~ /true/i)
    @group_name = Group.where(:id => @group_id).first.name rescue "Everyone"
    erb :game
  end

  # logic to get random people
  ['/random.json', '/:group/random.json'].each do |path|
    get path do
      content_type :json

      num = 4
      @correct_id = rand(num)
      @people = People.order("random()").limit(num)

      if params[:group] and not params[:group] =~ /all/i
        @people = @people.where(:group_id => params[:group])
      end

      @correct = @people[@correct_id]

      {
        description: @correct.description,
        original_thumbnail: @correct.thumbnail,
        thumbnail: "/img/thumbnail/#{@correct.id}.png",<commit_msg>Changing local files from png to jpg<commit_after>require 'rubygems'
require 'sinatra/base'
require 'sinatra/content_for'
require 'active_record'

ActiveRecord::Base.establish_connection(
  :adapter  => 'sqlite3',
  :database =>  'data/people.sqlite3.db'
)

connection_handle = ActiveRecord::Base.connection

class People < ActiveRecord::Base
  self.table_name = "people"
end

class Group < ActiveRecord::Base
  def url
    underscore_name = name.downcase.gsub(" ", "-")
    "/group/#{id}-#{underscore_name}"
  end
end

class GuessWho < Sinatra::Base
  helpers Sinatra::ContentFor

  helpers do
    def title
      sub = @group_name
      title = "Guess Who?"
      unless sub.nil?
        title += " | #{sub}"
      end
      return title
    end
  end

  # base route
  get '/' do
    @all_label = ENV["ALL_LABEL"] || "Everyone"
    @groups = Group.all
    erb :home
  end

  get '/group/:group' do
    @group_id = params[:group].split("-")[0]
    @api_end_point = "/#{@group_id}/random.json"
    @use_original_thumbnail = !!(ENV["ORINGAL_THUMBNAIL"] =~ /true/i)
    @group_name = Group.where(:id => @group_id).first.name rescue "Everyone"
    erb :game
  end

  # logic to get random people
  ['/random.json', '/:group/random.json'].each do |path|
    get path do
      content_type :json

      num = 4
      @correct_id = rand(num)
      @people = People.order("random()").limit(num)

      if params[:group] and not params[:group] =~ /all/i
        @people = @people.where(:group_id => params[:group])
      end

      @correct = @people[@correct_id]

      {
        description: @correct.description,
        original_thumbnail: @correct.thumbnail,
        thumbnail: "/img/thumbnail/#{@correct.id}.jpg",
{'fraction_non_alphanumeric': 0.14642752131725964, 'fraction_numerical': 0.0023522493384298734, 'mean_word_length': 3.02603550295858, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '439102', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1148, 'n_words': 249}