<commit_before>class SectionRepository
  NotFoundError = Module.new

  NO_DEFAULT_GIVEN = Object.new

  def fetchable_fetch(key, not_found_value = NO_DEFAULT_GIVEN)
    if not_found_value != NO_DEFAULT_GIVEN && block_given?
      raise ArgumentError.new("Cannot provide both a default arg and block to #fetch")
    end

    result = public_send(:[], key)

    if result.nil?
      return yield(key) if block_given?
      return not_found_value unless not_found_value == NO_DEFAULT_GIVEN

      raise KeyError.new("key not found #{key}")
    else
      result
    end
  end

  def fetch(*args, &block)
    fetchable_fetch(*args, &block)
  rescue KeyError => e
    raise e.extend(NotFoundError)
  end

  def initialize(manual:)
    @manual = manual
  end

  def [](id)
    editions = SectionEdition.all
      .where(section_id: id)
      .order_by([:version_number, :desc])
      .limit(2)
      .to_a
      .reverse

    if editions.empty?
      nil
    else<commit_msg>Update SectionRepository#fetch method signature<commit_after>class SectionRepository
  NotFoundError = Module.new

  NO_DEFAULT_GIVEN = Object.new

  def fetchable_fetch(key, not_found_value = NO_DEFAULT_GIVEN)
    if not_found_value != NO_DEFAULT_GIVEN && block_given?
      raise ArgumentError.new("Cannot provide both a default arg and block to #fetch")
    end

    result = public_send(:[], key)

    if result.nil?
      return yield(key) if block_given?
      return not_found_value unless not_found_value == NO_DEFAULT_GIVEN

      raise KeyError.new("key not found #{key}")
    else
      result
    end
  end

  def fetch(section_id)
    fetchable_fetch(section_id)
  rescue KeyError => e
    raise e.extend(NotFoundError)
  end

  def initialize(manual:)
    @manual = manual
  end

  def [](id)
    editions = SectionEdition.all
      .where(section_id: id)
      .order_by([:version_number, :desc])
      .limit(2)
      .to_a
      .reverse

    if editions.empty?
      nil
    else
{'fraction_non_alphanumeric': 0.08799593082400814, 'fraction_numerical': 0.001017293997965412, 'mean_word_length': 2.997967479674797, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5201364', 'n_tokens_mistral': 655, 'n_tokens_neox': 628, 'n_words': 160}