<commit_before>get '/challenge/:id' do |id|
  @challenge = Challenge.find(id)
  if request.xhr?
    erb :"challenge/single", layout:false
  else
    erb :"challenge/single"
  end
end

post '/user_challenge/:id' do |id|
  @challenge = Challenge.find(id)
  @result = UserChallenge.create(user_id: current_user.id, challenge_id: @challenge.id, success:params)
  if @result.success
    redirect "/page/#{@challenge.success_page.id}"
  else
    redirect "page/#{@challenge.fail_page.id}"
  end
end

get '/challenge/result/:id' do |id|
  user_challenge = UserChallenge.find(id)
  if user_challenge.success
    @page = user_challenge.success_page
  else
    @page = user_challenge.fail_page
  end
  redirect "/page/#{@page.id}"
end
<commit_msg>Challenge post request inputs results as well as next UserPage depending on result.<commit_after>get '/challenge/:id' do |id|
  @challenge = Challenge.find(id)
  if request.xhr?
    erb :"challenge/single", layout:false
  else
    erb :"challenge/single"
  end
end

post '/user_challenge/:id' do |id|
  @challenge = Challenge.find(id)
  @result = UserChallenge.create(user_id: current_user.id, challenge_id: @challenge.id, success:params)
  if @result.success
    UserPage.create(user_id: session[:user_id], page_id: @challenge.success_next_id )
    byebug
    redirect "/page/#{@challenge.success_next_id}"
  else
    UserPage.create(user_id: session[:user_id], page_id: @challenge.fail_next_id)
    redirect "page/#{@challenge.fail_next_id}"
  end
end

get '/challenge/result/:id' do |id|
  user_challenge = UserChallenge.find(id)
  if user_challenge.success
    @page = user_challenge.success_page
  else
    @page = user_challenge.fail_page
  end
  redirect "/page/#{@page.id}"
end

{'fraction_non_alphanumeric': 0.1294254207777133, 'fraction_numerical': 0.0, 'mean_word_length': 4.288343558282208, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '747241', 'n_tokens_mistral': 654, 'n_tokens_neox': 595, 'n_words': 129}