<commit_before>class Participant < ActiveRecord::Base
  SORT_ORDERS = %i(total_score maneuver_score participant_name participant_number)

  belongs_to :bus
  has_many :maneuver_participants, dependent: :destroy
  has_many :maneuvers, through: :maneuver_participants
  has_one :circle_check_score, dependent: :destroy
  has_one :quiz_score, dependent: :destroy
  has_one :onboard_judging, dependent: :destroy

  validates :name, presence: true, uniqueness: true

  default_scope { order :number }

  scope :numbered, -> { where.not number: nil }
  scope :not_numbered, -> { where number: nil }

  def has_completed?(maneuver)
    maneuvers.include? maneuver
  end

  def maneuver_record(maneuver)
    maneuver_participants.find_by maneuver: maneuver
  end

  def maneuver_score
    maneuver_participants.sum :score
  end

  def name_and_number
    if number
      "#{name} (##{number})"
    else name
    end
  end

  def total_score
    total = maneuver_score<commit_msg>added validations<commit_after>class Participant < ActiveRecord::Base
  SORT_ORDERS = %i(total_score maneuver_score participant_name participant_number)

  belongs_to :bus
  has_many :maneuver_participants, dependent: :destroy
  has_many :maneuvers, through: :maneuver_participants
  has_one :circle_check_score, dependent: :destroy
  has_one :quiz_score, dependent: :destroy
  has_one :onboard_judging, dependent: :destroy

  validates :name, presence: true, uniqueness: true
  validates :bus, presence: true, if: -> { number.present? }

  default_scope { order :number }

  scope :numbered, -> { where.not number: nil }
  scope :not_numbered, -> { where number: nil }

  def has_completed?(maneuver)
    maneuvers.include? maneuver
  end

  def maneuver_record(maneuver)
    maneuver_participants.find_by maneuver: maneuver
  end

  def maneuver_score
    maneuver_participants.sum :score
  end

  def name_and_number
    if number
      "#{name} (##{number})"
    else name
    end
  end

  def total_score
    total = maneuver_score
{'fraction_non_alphanumeric': 0.08221225710014948, 'fraction_numerical': 0.0, 'mean_word_length': 4.412398921832884, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '7454179', 'n_tokens_mistral': 691, 'n_tokens_neox': 636, 'n_words': 164}