<commit_before>get '/answers/all' do
  @answers = Answer.all
  # this should go to
  erb :index
end

post '/answers' do
  if request.xhr?
    @question = Question.find(params[:question_id])
    @answer = Answer.create(params[:answer])
    @question.answers << @answer
    erb :'/answers/show', locals: {answer: @answer}, layout: false
  else
    erb :'/questions/show'
  end
end

put '/answers/:id/edit' do
   @answer = Answer.find(params[:id])
   @answer.update(params[:answer])
   content_type :json
   params[:answer].to_json
end


delete '/answers/:id' do
  @answer = Answer.find(params[:id])
  @answer.destroy
end

get '/answers/:id/upvote' do
  check_auth
  @answer = Answer.find(params[:id])
  @answer.votes.create(value: 1)
  if request.xhr?
    id = @answer.id
    tally = @answer.vote_tally
    content_type :json
    JSON.generate(id: id, tally: tally)
  # else
  #   redirect '/questions/#{@answer.id}'
  end
end

get '/answers/:id/downvote' do
  check_auth
  @answer = Answer.find(params[:id])
  @answer.votes.create(value: -1)
  if request.xhr?
    id = @answer.id
    tally = @answer.vote_tally
    content_type :json
    JSON.generate(id: id, tally: tally)
  # else
  #   redirect '/questions/#{@answer.id}'
  end
end
<commit_msg>Remove else statements<commit_after>get '/answers/all' do
  @answers = Answer.all
  # this should go to
  erb :index
end

post '/answers' do
  if request.xhr?
    @question = Question.find(params[:question_id])
    @answer = Answer.create(params[:answer])
    @question.answers << @answer
    erb :'/answers/show', locals: {answer: @answer}, layout: false
  else
    erb :'/questions/show'
  end
end

put '/answers/:id/edit' do
   @answer = Answer.find(params[:id])
   @answer.update(params[:answer])
   content_type :json
   params[:answer].to_json
end


delete '/answers/:id' do
  @answer = Answer.find(params[:id])
  @answer.destroy
end

get '/answers/:id/upvote' do
  check_auth
  @answer = Answer.find(params[:id])
  @answer.votes.create(value: 1)
  if request.xhr?
    id = @answer.id
    tally = @answer.vote_tally
    content_type :json
    JSON.generate(id: id, tally: tally)
  end
end

get '/answers/:id/downvote' do
  check_auth
  @answer = Answer.find(params[:id])
  @answer.votes.create(value: -1)
  if request.xhr?
    id = @answer.id
    tally = @answer.vote_tally
    content_type :json
    JSON.generate(id: id, tally: tally)
  end
end

{'fraction_non_alphanumeric': 0.1492288453522301, 'fraction_numerical': 0.0016673614005835765, 'mean_word_length': 3.387568555758684, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7524881', 'n_tokens_mistral': 915, 'n_tokens_neox': 884, 'n_words': 200}