<commit_before># index
get "/questions/:id/comments" do
  redirect "questions/#{params[:id]}"
end


# get new comment
get "/questions/:id/comments/new" do
  @question = Question.find_by_id(params[:id])

  erb :"comments/new"
end

# post a new comment
post "/questions/:id/comments" do
  @question = Question.find_by_id(params[:id])
  @comment = @question.comments.new(comment: params[:comment],
                            user_id: current_user.id)

  if @comment.save
    redirect "questions/#{@question.id}"
  else
    @errors = @comment.errors.full_messages
    erb :"comments/new"
  end
end

# show
get "/questions/:q_id/comments/:id" do
  redirect "questions/#{params[:q_id]}"
end

# get edit form
get "/questions/:q_id/comments/:id/edit" do
  @question = Question.find_by_id(params[:q_id])
  @comment = Comment.find_by_id(params[:id])

  erb :"comments/edit"
end

# Update comment
put "/questions/:q_id/comments/:id" do
  @question = Question.find_by_id(params[:q_id])
  @comment = Comment.find_by_id(params[:id])

  if @comment.update(comment: params[:comment])
    redirect "questions/#{@question.id}"
  else
    @errors = @comment.errors.full_messages
    erb :"comments/edit"
  end
end

# Delete comment
delete "/questions/:q_id/comments/:id" do
  Comment.find_by_id(params[:id]).destroy
  
  redirect "questions/#{params[:id]}"
end
<commit_msg>add delete logic<commit_after># index
get "/questions/:id/comments" do
  redirect "questions/#{params[:id]}"
end


# get new comment
get "/questions/:id/comments/new" do
  @question = Question.find_by_id(params[:id])

  erb :"comments/new"
end

# post a new comment
post "/questions/:id/comments" do
  @question = Question.find_by_id(params[:id])
  @comment = @question.comments.new(comment: params[:comment],
                            user_id: current_user.id)

  if @comment.save
    redirect "questions/#{@question.id}"
  else
    @errors = @comment.errors.full_messages
    erb :"comments/new"
  end
end

# show
get "/questions/:q_id/comments/:id" do
  redirect "questions/#{params[:q_id]}"
end

# get edit form
get "/questions/:q_id/comments/:id/edit" do
  @question = Question.find_by_id(params[:q_id])
  @comment = Comment.find_by_id(params[:id])

  erb :"comments/edit"
end

# Update comment
put "/questions/:q_id/comments/:id" do
  @question = Question.find_by_id(params[:q_id])
  @comment = Comment.find_by_id(params[:id])

  if @comment.update(comment: params[:comment])
    redirect "questions/#{@question.id}"
  else
    @errors = @comment.errors.full_messages
    erb :"comments/edit"
  end
end

# Delete comment
delete "/questions/:q_id/comments/:id" do
  Comment.find_by_id(params[:id]).destroy

  redirect "questions/#{params[:q_id]}"
end

{'fraction_non_alphanumeric': 0.15481017323995577, 'fraction_numerical': 0.0, 'mean_word_length': 4.054003724394786, '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': '488314', 'n_tokens_mistral': 964, 'n_tokens_neox': 950, 'n_words': 190}