<commit_before>get '/logs/new' do
   erb :_log_form, :layout => false
end

get '/logs/:id' do
  @log = Log.find(params[:id])
  erb :'logs/show'
end

post '/logs/:id/like' do
  id = params[:id].to_i
  log = Log.find(params[:id])
  #if log.likes
  log.likes.create(value: 1)
  if request.xhr?
    content_type :json
    {log_id: id, likes: log.points}.to_json
  else
    redirect "/"
  end
end

post '/logs/:id/follow' do

  current_user = User.find(session[:user_id]) if session[:user_id]
  log_of_user = Log.find(params[:id])
  user_to_follow = log_of_user.user

  if !user_to_follow.followers.include?(current_user)
    current_user.followees << user_to_follow
    current_user.save
  end

  if request.xhr?
    id = params[:id].to_i
    @log = Log.find(id)
    fcount = @log.user.followers.count
    unfollow_but = erb :_unfollowbutton, :layout => false
    content_type :json
    {log_id: id, unfollow: unfollow_but, fcount: fcount}.to_json
  else
    redirect "/"
  end
end




post '/logs/:id/unfollow' do
  current_user = User.find(session[:user_id]) if session[:user_id]
  log_of_user = Log.find(params[:id])
  user_to_follow = log_of_user.user
  current_user.followees.delete(user_to_follow)
  current_user.save


if request.xhr?
    id = params[:id].to_i
    @log = Log.find(id)
    fcount = @log.user.followers.count
    follow_but = erb :followbut, :layout => false
    content_type :json
    {log_id: id, follow: follow_but, fcount: fcount}.to_json
  else
    redirect "/"
end

end





post '/logs' do
  p "stars" * 300

  Log.create( user_id: current_user.id, title: params[:title], duration: params[:duration], mood: params[:mood], location: params[:location])
  if request.xhr?
     p "blah"*30
    @logs = Log.all
    @log = Log.last
    erb :_new_log, :layout => false
  else
    redirect '/'
  end
end<commit_msg>change indentation log controller<commit_after>get '/logs/new' do
   erb :_log_form, :layout => false
end

get '/logs/:id' do
  @log = Log.find(params[:id])
  erb :'logs/show'
end

post '/logs/:id/like' do
  id = params[:id].to_i
  log = Log.find(params[:id])
  #if log.likes
  log.likes.create(value: 1)
  if request.xhr?
    content_type :json
    {log_id: id, likes: log.points}.to_json
  else
    redirect "/"
  end
end

post '/logs/:id/follow' do

  current_user = User.find(session[:user_id]) if session[:user_id]
  log_of_user = Log.find(params[:id])
  user_to_follow = log_of_user.user

  if !user_to_follow.followers.include?(current_user)
    current_user.followees << user_to_follow
    current_user.save
  end

  if request.xhr?
    id = params[:id].to_i
    @log = Log.find(id)
    fcount = @log.user.followers.count
    unfollow_but = erb :_unfollowbutton, :layout => false
    content_type :json
    {log_id: id, unfollow: unfollow_but, fcount: fcount}.to_json
  else
    redirect "/"
  end
end




post '/logs/:id/unfollow' do
  current_user = User.find(session[:user_id]) if session[:user_id]
  log_of_user = Log.find(params[:id])
  user_to_follow = log_of_user.user
  current_user.followees.delete(user_to_follow)
  current_user.save
if request.xhr?
    id = params[:id].to_i
    @log = Log.find(id)
    fcount = @log.user.followers.count
    follow_but = erb :followbut, :layout => false
    content_type :json
    {log_id: id, follow: follow_but, fcount: fcount}.to_json
  else
    redirect "/"
end

end





post '/logs' do
  p "stars" * 300

  Log.create( user_id: current_user.id, title: params[:title], duration: params[:duration], mood: params[:mood], location: params[:location])
  if request.xhr?
     p "blah"*30
    @logs = Log.all
    @log = Log.last
    erb :_new_log, :layout => false
  else
    redirect '/'
  end
end
{'fraction_non_alphanumeric': 0.13688212927756654, 'fraction_numerical': 0.0032590983161325366, 'mean_word_length': 3.4266826923076925, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '6921881', 'n_tokens_mistral': 1425, 'n_tokens_neox': 1399, 'n_words': 306}