<commit_before>class ExternallyRankedCalculator

  def initialize(competition)
    @competition = competition
  end

  # update the places for all age groups
  def update_all_places
    age_group_type = @competition.determine_age_group_type
    unless age_group_type.nil?
      age_group_type.age_group_entries.each do |age|
        update_places(age.to_s)
      end
    end
    update_overall_places("Male")
    update_overall_places("Female")
  end


  private
  # update the places for an event, fastest first.
  # DQ are marked as place = 0
  # results with time==0 are marked as place = 0
  def update_places(age_group_entry_description)
    return 0 if age_group_entry_description.nil?

    @competition.external_results.order("rank").each do |er|

      # only perform updates on the specified age group entry set
      next if er.competitor.age_group_entry_description != age_group_entry_description

      er.competitor.place = er.rank
    end
  end

  def update_overall_places(gender)

    @competition.external_results.order("rank").each do |er|
      next if er.competitor.gender != gender

      er.competitor.overall_place = er.rank
    end
  end
end<commit_msg>separet the external ranking from the internal placing<commit_after>class ExternallyRankedCalculator

  def initialize(competition)
    @competition = competition
  end

  # update the places for all age groups
  def update_all_places
    age_group_type = @competition.determine_age_group_type
    unless age_group_type.nil?
      age_group_type.age_group_entries.each do |age|
        update_places(age.to_s)
      end
    end
    update_overall_places("Male")
    update_overall_places("Female")
  end


  private
  # update the places for an event, fastest first.
  # DQ are marked as place = 0
  # results with time==0 are marked as place = 0
  def update_places(age_group_entry_description)
    return 0 if age_group_entry_description.nil?

    rank = 1
    @competition.external_results.order("rank").each do |er|

      # only perform updates on the specified age group entry set
      next if er.competitor.age_group_entry_description != age_group_entry_description

      er.competitor.place = rank
      rank += 1
    end
  end

  def update_overall_places(gender)

    rank = 1
    @competition.external_results.order("rank").each do |er|
      next if er.competitor.gender != gender

      er.competitor.overall_place = rank
      rank += 1
    end
  end
end
{'fraction_non_alphanumeric': 0.06702084184715978, 'fraction_numerical': 0.004903964037597058, 'mean_word_length': 3.4187725631768955, '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': '5545735', 'n_tokens_mistral': 787, 'n_tokens_neox': 742, 'n_words': 200}