<commit_before>get '/posts' do

  erb :'/posts/index'
end

get '/posts/new' do
  erb :'/posts/new'
end

post '/posts' do
  post = current_user.posts.new(params[:post])
  tags = params[:tags].split()
  tags.each do |tag|
    current_user.posts.find_or_create_by(name: tag)
  end
  if post.save
    redirect '/posts/#{post.id}'
  else
    @errors = post.errors.full_messages
    erb :'/posts/new'
  end
end

get '/posts/:id' do
  @post = Post.find(params[:id])
  @post.views += 1
  @post.save
  @answer = @post.answers
  erb :'/posts/show'
end<commit_msg>update post controller to create a post with the specified tags<commit_after>get '/posts' do

  erb :'/posts/index'
end

get '/posts/new' do
  @tags = Tag.all.sort{ |x,y| y.posts.length <=> x.posts.length }
  erb :'/posts/new'
end

post '/posts' do
  @post = current_user.posts.new(params[:post])
  @tags = params[:tags]
  @tags.map! { |tag| Tag.find_by(name:tag) }
  @post.tags << @tags
  if @post.save
    redirect "/posts/#{@post.id}"
  else
    @tags = Tag.all.sort{ |x,y| y.posts.length <=> x.posts.length }
    @errors = @post.errors.full_messages
    erb :'/posts/new'
  end
end

get '/posts/:id' do
  @post = Post.find(params[:id])
  @post.views += 1
  @post.save
  @answer = @post.answers
  erb :'/posts/show'
end
{'fraction_non_alphanumeric': 0.1772549019607843, 'fraction_numerical': 0.001568627450980392, 'mean_word_length': 3.1699346405228757, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '3708731', 'n_tokens_mistral': 517, 'n_tokens_neox': 504, 'n_words': 116}