<commit_before>require 'sinatra/base'
require 'sinatra/main'
require 'mysql'

enable :inline_templates
set :views, File.dirname(__FILE__) + '/views'

get '/' do
	erb :index
end

get '/graph' do
  haml :graph
end

get '/data' do
  res = ""
  ender = "{"
  begin
     # connect to the MySQL server
     dbh = Mysql.real_connect("localhost", "root", "", "bitcoin")
     # get server version string and display it
  rescue Mysql::Error => e
     puts "Error code: #{e.errno}"
     puts "Error message: #{e.error}"
     puts "Error SQLSTATE: #{e.sqlstate}" if e.respond_to?("sqlstate")
  else
     if !params[:last].nil?
    	res = dbh.query("SELECT * FROM stat WHERE time >" + params[:last])
     elsif !params[:many].nil?
     	res = dbh.query("SELECT * FROM stat ORDER BY time DESC LIMIT "+params[:many])
     else
     	res = dbh.query("SELECT * FROM stat ORDER BY time DESC LIMIT 10")
     end
     res.each do |row|
     	ender = "#{ender}  \"#{row[1]}\":{\"total\":#{row[2]}, \"avg\":#{row[3]}, \"max\":#{row[4]}, \"min\":#{row[5]}, \"count\":#{row[6]}}, "
     end
     ender = ender + "}"
  ensure
     # disconnect from server
     dbh.close if dbh
  end
  return ender 
end<commit_msg>got rid of the trailing comma inside of the object<commit_after>require 'sinatra/base'
require 'sinatra/main'
require 'mysql'

enable :inline_templates
set :views, File.dirname(__FILE__) + '/views'

get '/' do
	erb :index
end

get '/graph' do
  haml :graph
end

get '/data' do
  res = ""
  ender = "{"
  begin
     # connect to the MySQL server
     dbh = Mysql.real_connect("localhost", "root", "", "bitcoin")
     # get server version string and display it
  rescue Mysql::Error => e
     puts "Error code: #{e.errno}"
     puts "Error message: #{e.error}"
     puts "Error SQLSTATE: #{e.sqlstate}" if e.respond_to?("sqlstate")
  else
     if !params[:last].nil?
    	res = dbh.query("SELECT * FROM stat WHERE time >" + params[:last])
     elsif !params[:many].nil?
     	res = dbh.query("SELECT * FROM stat ORDER BY time DESC LIMIT "+params[:many])
     else
     	res = dbh.query("SELECT * FROM stat ORDER BY time DESC LIMIT 10")
     end
     res.each do |row|
     	ender = "#{ender}  \"#{row[1]}\":{\"total\":#{row[2]}, \"avg\":#{row[3]}, \"max\":#{row[4]}, \"min\":#{row[5]}, \"count\":#{row[6]}}, "
     end
     comma = ender.length - 2
     ender = ender[0,comma] + "}"
  ensure
     # disconnect from server
     dbh.close if dbh
  end
  return ender 
end
{'fraction_non_alphanumeric': 0.17493897477624085, 'fraction_numerical': 0.007323026851098454, 'mean_word_length': 2.9789644012944985, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 7, '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': '6460284', 'n_tokens_mistral': 875, 'n_tokens_neox': 874, 'n_words': 251}