<commit_before>class UsersController < ApplicationController
  def show
    @user = User.find_by_nickname(params[:nickname])
    @feats = @user.completed_feats.reverse
    @all_feat_count = Feat.count
    @percent = ((@feats.count.to_f/@all_feat_count.to_f)*100).to_i
    @command_history = @user.command_histories

    @total = roundup(@feats.count, 3)
    @github_url = "http://www.github.com/#{@user.nickname}" 

    # Setup data
    @api_key = "#{@user.nickname}-#{@user.gemkey}"
    @install_cmd = "gem install git-feats"
    @conf_cmd = format_conf_command(@api_key)
    @alias_cmd = "echo 'alias git=git-feats' >> .bashrc"
    @one_liner = [@conf_cmd, @install_cmd, @alias_cmd].join(" && ") 
  end

  def search 
    @user = User.find_by_nickname(params[:query])

    # if empty query, redirect them back. <~ there has to be a better way
    if params[:query].empty?
      redirect_to(:back)
      
    # else if the search for user fails, go back and tell them
    elsif @user.nil?
      redirect_to(:back, :notice => "Could not find user #{params[:query]}")

    # else take them to the users page
    else
      redirect_to @user
    end
  end 

  private

  def roundup (num, ceiling)<commit_msg>balls... missed a error case<commit_after>class UsersController < ApplicationController
  def show
    @user = User.find_by_nickname(params[:nickname])
    @feats = @user.completed_feats.reverse
    @all_feat_count = Feat.count
    @percent = ((@feats.count.to_f/@all_feat_count.to_f)*100).to_i
    @command_history = @user.command_histories

    @total = roundup(@feats.count, 3)
    @github_url = "http://www.github.com/#{@user.nickname}" 

    # Setup data
    @api_key = "#{@user.nickname}-#{@user.gemkey}"
    @install_cmd = "gem install git-feats"
    @conf_cmd = format_conf_command(@api_key)
    @alias_cmd = "echo 'alias git=git-feats' >> .bashrc"
    @one_liner = [@conf_cmd, @install_cmd, @alias_cmd].join(" && ") 
  end

  def search 
    @user = User.find_by_nickname(params[:query])

    if params[:query].nil?
      redirect_to :root

    # if empty query, redirect them back. <~ there has to be a better way
    elsif params[:query].empty?
      redirect_to(:back)

    # else if the search for user fails, go back and tell them
    elsif @user.nil?
      redirect_to(:back, :notice => "Could not find user #{params[:query]}")

    # else take them to the users page
    else
      redirect_to @user
    end
  end 

  private

  def roundup (num, ceiling)
{'fraction_non_alphanumeric': 0.13196125907990314, 'fraction_numerical': 0.003228410008071025, 'mean_word_length': 3.2889273356401385, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2996655', 'n_tokens_mistral': 874, 'n_tokens_neox': 833, 'n_words': 203}