<commit_before>class GoalsController < ApplicationController
# display list of all goals
  def index
    @goals = current_user.goals
    @title = "All goals for #{current_user.profile.first_name}"
  end

  # return an HTML form to add new goal
  def new
    @title = 'Add a goal'
    @goal = Goal.new
  end

  # create a new goal
  def create
    @goal = Goal.new params[:goal]
    if @goal.save
      current_user.goals << @goal
    else
      flash.now[:error] = 'There was a problem saving your new goal.'
      flash.now[:errors] = @goal.errors
      redirect_to :action => "new"
    end
    redirect_to :action => 'show', :id => @goal.id
  end

  # display a specific goal
  def show<commit_msg>added an if check to determine whether to use username or profile.first_name for the goals index title. Avoid exception that occurs when user has not completed their profile yet.<commit_after>class GoalsController < ApplicationController
# display list of all goals
  def index
    @goals = current_user.goals
    if current_user.profile
      name = current_user.profile.first_name
    else
      name = current_user.username
    end
      @title = "All goals for #{name}"
  end

  # return an HTML form to add new goal
  def new
    @title = 'Add a goal'
    @goal = Goal.new
  end

  # create a new goal
  def create
    @goal = Goal.new params[:goal]
    if @goal.save
      current_user.goals << @goal
    else
      flash.now[:error] = 'There was a problem saving your new goal.'
      flash.now[:errors] = @goal.errors
      redirect_to :action => "new"
    end
    redirect_to :action => 'show', :id => @goal.id
  end

  # display a specific goal
  def show
{'fraction_non_alphanumeric': 0.08828828828828829, 'fraction_numerical': 0.0, 'mean_word_length': 2.769230769230769, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '955054', 'n_tokens_mistral': 524, 'n_tokens_neox': 503, 'n_words': 187}