<commit_before>class PerformanceCompetitionSeries::Scoreboard::Standings::Row
  attr_accessor :rank
  attr_reader :competitor

  def initialize(competitor, results, rounds)
    @competitor = competitor
    @results = results
    @rounds = rounds
  end

  def total_points
    points_in_disciplines.sum { |_discipline, points| points }.round(1)
  end

  def points_in_disciplines
    @points_in_disciplines ||=
      rounds_by_discipline.each_with_object({}) do |(discipline, rounds), memo|
        active_rounds = rounds.select(&:completed)
        next if active_rounds.count.zero?

        sum_of_points =
          active_rounds
          .map { |round| result_in_round(round) }
          .compact
          .sum(&:points)

        memo[discipline] = sum_of_points.to_f / active_rounds.count
      end
  end

  def result_in_round(round)
    results.find { |result| round.includes?(result.round) }
  end

  private

  attr_reader :results, :rounds

  def rounds_by_discipline = rounds.group_by(&:discipline)
end<commit_msg>Fix nil coercion error in Performance Competition Series<commit_after>class PerformanceCompetitionSeries::Scoreboard::Standings::Row
  attr_accessor :rank
  attr_reader :competitor

  def initialize(competitor, results, rounds)
    @competitor = competitor
    @results = results
    @rounds = rounds
  end

  def total_points
    points_in_disciplines.sum { |_discipline, points| points }.round(1)
  end

  def points_in_disciplines
    @points_in_disciplines ||=
      rounds_by_discipline.each_with_object({}) do |(discipline, rounds), memo|
        active_rounds = rounds.select(&:completed)
        next if active_rounds.count.zero?

        sum_of_points =
          active_rounds
          .map { |round| result_in_round(round) }
          .compact
          .sum { |result| result.points.to_f }

        memo[discipline] = sum_of_points.to_f / active_rounds.count
      end
  end

  def result_in_round(round)
    results.find { |result| round.includes?(result.round) }
  end

  private

  attr_reader :results, :rounds

  def rounds_by_discipline = rounds.group_by(&:discipline)
end
{'fraction_non_alphanumeric': 0.09069437883797828, 'fraction_numerical': 0.000944733112895607, 'mean_word_length': 3.3580246913580245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1464340', 'n_tokens_mistral': 703, 'n_tokens_neox': 659, 'n_words': 136}