<commit_before>require 'sinatra'
#require 'sinatra/activerecord'
#require './config/environments' #database configuration
#require './models/model'        #Model class
require 'json'
require 'set'

$connections = {}
$conlist = []

def tuple(params)
  users,video = params["users"].sort,params["video"]
  return "#{params["users"].join(",")} => #{params["video"]}"
end

def validate_json(data)
  data && data['users'] && !data['users'].empty? && data['video']
end

def json_error(msg)
  return {Error: msg}.to_json
end 

get '/' do
  'Noone should see this'
end

def mintime(hash)
  return hash.values.min
end

#This method checks if everyone is ok with stuff playing
post '/keepalive' do
  content_type :json
  user = @data['user']
  tnew = @data['time']
  conn = $conlist[@data['c_id']]
  time = conn[:time][user]
  puts ">>>>#{conn[:time][user]}"
  conn[:time][user] = time < tnew ? tnew : time
  #if conn[:seeking]
  return {skip: conn[:rdy].empty? , time: mintime(conn[:time])}.to_json
  #else
  #  return conn[:rdy].empty? ? 200 : 406
end

get '/redirect/:c_cid/:uid' do
end

get '/caguei/:c_id' do
  cid = params[:c_id].to_i
  $connections.delete($conlist[cid][:state])
  $conlist[cid] = nil
end

before do<commit_msg>fixing bork<commit_after>require 'sinatra'
#require 'sinatra/activerecord'
#require './config/environments' #database configuration
#require './models/model'        #Model class
require 'json'
require 'set'

$connections = {}
$conlist = []

def tuple(params)
  users,video = params["users"].sort,params["video"]
  return "#{params["users"].join(",")} => #{params["video"]}"
end

def validate_json(data)
  data && data['users'] && !data['users'].empty? && data['video']
end

def json_error(msg)
  return {Error: msg}.to_json
end 

get '/' do
  'Noone should see this'
end

def mintime(hash)
  return hash.values.min
end

#This method checks if everyone is ok with stuff playing
post '/keepalive' do
  content_type :json
  user = @data['user']
  tnew = @data['time']
  conn = $conlist[@data['c_id'].to_i]
  time = conn[:time][user]
  puts ">>>>#{conn[:time][user]}"
  conn[:time][user] = time < tnew ? tnew : time
  #if conn[:seeking]
  return {skip: conn[:rdy].empty? , time: mintime(conn[:time])}.to_json
  #else
  #  return conn[:rdy].empty? ? 200 : 406
end

get '/redirect/:c_cid/:uid' do
end

get '/caguei/:c_id' do
  cid = params[:c_id].to_i
  $connections.delete($conlist[cid][:state])
  $conlist[cid] = nil
end

before do
{'fraction_non_alphanumeric': 0.18482252141982863, 'fraction_numerical': 0.004895960832313341, 'mean_word_length': 4.636781609195403, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '4851447', 'n_tokens_mistral': 905, 'n_tokens_neox': 896, 'n_words': 218}