<commit_before>class RaceResult < ApplicationRecord
  belongs_to :racer
  belongs_to :race
  attr_accessor :racer_start_number

  validate :disallow_duplicates

  def disallow_duplicates
    return if self.id
    errors.add(:racer, 'prijava vec postoji!') if RaceResult.exists?(racer: self.racer, race: self.race)
  end

  def pretty_status
    case status
    when 1
      'Prijavljen'
    when 2
      'Na startu'
    when 3
      'Zavrsio'
    when 4
      'DNF'
    when 5
      'DSQ'
    when 6
      'DNS'
    else
      'Nepoznat'
    end
  end

  def finish_time
    if race && lap_times.length > 0
      seconds = Time.at(lap_times.last.to_f) - race.started_at
      Time.at(seconds).utc.strftime("%H:%M:%S.%L")
    else
      '- -'
    end
  end

  def to_csv
    # ['Startni broj', 'Ime', 'Prezime', 'Klub',
    # 'Godiste', 'Prebivaliste', 'Email', 'Mobitel', 'Vrijeme', 'Status', 'Bodovi']
    return [racer.start_number, racer.first_name, racer.last_name, racer.club.try(:name),
      racer.year_of_birth, racer.town, racer.email, racer.phone_number, finish_time, status, points]
  end
end<commit_msg>Show start_number value in csv<commit_after>class RaceResult < ApplicationRecord
  belongs_to :racer
  belongs_to :race
  attr_accessor :racer_start_number

  validate :disallow_duplicates

  def disallow_duplicates
    return if self.id
    errors.add(:racer, 'prijava vec postoji!') if RaceResult.exists?(racer: self.racer, race: self.race)
  end

  def pretty_status
    case status
    when 1
      'Prijavljen'
    when 2
      'Na startu'
    when 3
      'Zavrsio'
    when 4
      'DNF'
    when 5
      'DSQ'
    when 6
      'DNS'
    else
      'Nepoznat'
    end
  end

  def finish_time
    if race && lap_times.length > 0
      seconds = Time.at(lap_times.last.to_f) - race.started_at
      Time.at(seconds).utc.strftime("%H:%M:%S.%L")
    else
      '- -'
    end
  end

  def to_csv
    # ['Start<NAME>', 'Ime', 'Prezime', 'Klub',
    # 'Godiste', 'Prebivaliste', 'Email', 'Mobitel', 'Vrijeme', 'Status', 'Bodovi']
    return [racer.start_number&.value, racer.first_name, racer.last_name, racer.club&.name,
      racer.year_of_birth, racer.town, racer.email, racer.phone_number, finish_time, status, points]
  end
end
{'fraction_non_alphanumeric': 0.11832740213523131, 'fraction_numerical': 0.006227758007117438, 'mean_word_length': 2.831345826235094, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '4006016', 'n_tokens_mistral': 881, 'n_tokens_neox': 848, 'n_words': 190}