<commit_before>class Punchcard < ApplicationRecord
  belongs_to :user
  has_many :records, dependent: :destroy
  has_one :goal
  accepts_nested_attributes_for :goal

  validates :name, :presence => true


  def total_hours
    self.records.sum(:hours)
  end

  def current_month_hours
    self.records.where(date: Time.now.beginning_of_month..Time.now.end_of_month).sum(:hours)
  end

  def start_time
    unless self.records.empty?
      self.records.first.created_at.strftime('%B %d %Y')
    else
      self.created_at.strftime('%B %d %Y')
    end
  end

end<commit_msg>Fix nil check on first record<commit_after>class Punchcard < ApplicationRecord
  belongs_to :user
  has_many :records, dependent: :destroy
  has_one :goal
  accepts_nested_attributes_for :goal

  validates :name, :presence => true


  def total_hours
    self.records.sum(:hours)
  end

  def current_month_hours
    self.records.where(date: Time.now.beginning_of_month..Time.now.end_of_month).sum(:hours)
  end

  def start_time
    if self.records.first.present?
      self.records.first.created_at.strftime('%B %d %Y')
    else
      self.created_at.strftime('%B %d %Y')
    end
  end

end
{'fraction_non_alphanumeric': 0.10223367697594501, 'fraction_numerical': 0.0, 'mean_word_length': 3.716599190283401, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5412570', 'n_tokens_mistral': 426, 'n_tokens_neox': 403, 'n_words': 84}