<commit_before>get '/surveys' do
  user_and_other_surveys = Survey.created_and_not_created_by(current_user,Survey.all)

  @user_surveys = user_and_other_surveys[0]
  other_surveys = user_and_other_surveys[1]

  taken_and_not_taken_surveys = Survey.taken_and_not_taken_by(current_user, other_surveys)
  @surveys_taken = taken_and_not_taken_surveys[0]
  @surveys_not_taken = taken_and_not_taken_surveys[1]

  erb :'/surveys/index'
end

get '/surveys/new' do
  erb :"/surveys/new"
end

get '/surveys/:id' do
  @survey = Survey.find_by(id: params[:id])
  @user = @survey.user
  erb :"/surveys/show"
end

post "/surveys" do
  @survey = Survey.new(params[:survey])
  @survey.user = current_user
  if @survey.save
    redirect "/surveys/#{@survey.id}"
  else
    @errors = @survey.errors.full_messages
    erb :"/surveys/edit"
  end
end

get '/surveys/:id/edit' do
  @survey = Survey.find_by(id: params[:id])
  erb :"/surveys/edit"
end

get '/surveys/:id/results' do
  @survey = Survey.find_by(id: params[:id])
  @questions = @survey.questions
  @questions_results = []

  @questions.each do |question|
    @questions_results << question.compiled_results
  end

  erb :"/surveys/results"
end

put '/surveys/:id' do
  @survey = Survey.find_by(id: params[:id])
  if @survey.update(params[:survey])
    redirect "/surveys/#{@survey.id}/edit"
  else
    @errors = @survey.errors.full_messages
    erb :"/surveys/edit"
  end<commit_msg>Change questions variable in /surveys_user/:id/results from instance to local<commit_after>get '/surveys' do
  user_and_other_surveys = Survey.created_and_not_created_by(current_user,Survey.all)

  @user_surveys = user_and_other_surveys[0]
  other_surveys = user_and_other_surveys[1]

  taken_and_not_taken_surveys = Survey.taken_and_not_taken_by(current_user, other_surveys)
  @surveys_taken = taken_and_not_taken_surveys[0]
  @surveys_not_taken = taken_and_not_taken_surveys[1]

  erb :'/surveys/index'
end

get '/surveys/new' do
  erb :"/surveys/new"
end

get '/surveys/:id' do
  @survey = Survey.find_by(id: params[:id])
  @user = @survey.user
  erb :"/surveys/show"
end

post "/surveys" do
  @survey = Survey.new(params[:survey])
  @survey.user = current_user
  if @survey.save
    redirect "/surveys/#{@survey.id}"
  else
    @errors = @survey.errors.full_messages
    erb :"/surveys/edit"
  end
end

get '/surveys/:id/edit' do
  @survey = Survey.find_by(id: params[:id])
  erb :"/surveys/edit"
end

get '/surveys/:id/results' do
  @survey = Survey.find_by(id: params[:id])
  questions = @survey.questions
  @questions_results = []

  questions.each do |question|
    @questions_results << question.compiled_results
  end

  erb :"/surveys/results"
end

put '/surveys/:id' do
  @survey = Survey.find_by(id: params[:id])
  if @survey.update(params[:survey])
    redirect "/surveys/#{@survey.id}/edit"
  else
    @errors = @survey.errors.full_messages
    erb :"/surveys/edit"
  end
{'fraction_non_alphanumeric': 0.13883161512027492, 'fraction_numerical': 0.0027491408934707906, 'mean_word_length': 4.390740740740741, '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': '6596806', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1188, 'n_words': 201}