<commit_before>class PublishingApiManualWithSectionsPublisher
  def call(manual, action = nil)
    update_type = (action == :republish ? "republish" : nil)
    PublishingAPIPublisher.new(
      entity: manual,
      update_type: update_type,
    ).call

    manual.sections.each do |document|
      next if !document.needs_exporting? && action != :republish

      PublishingAPIPublisher.new(
        entity: document,
        update_type: update_type,
      ).call

      document.mark_as_exported! if action != :republish
    end

    manual.removed_sections.each do |document|
      next if document.withdrawn? && action != :republish
      begin
        publishing_api_v2.unpublish(document.id, type: "redirect", alternative_path: "/#{manual.slug}", discard_drafts: true)
      rescue GdsApi::HTTPNotFound # rubocop:disable Lint/HandleExceptions
      end
      document.withdraw_and_mark_as_exported! if action != :republish
    end
  end

  def publishing_api_v2
    Services.publishing_api_v2
  end
end<commit_msg>Rename document -> section in PublishingApiManualWithSectionsPublisher<commit_after>class PublishingApiManualWithSectionsPublisher
  def call(manual, action = nil)
    update_type = (action == :republish ? "republish" : nil)
    PublishingAPIPublisher.new(
      entity: manual,
      update_type: update_type,
    ).call

    manual.sections.each do |section|
      next if !section.needs_exporting? && action != :republish

      PublishingAPIPublisher.new(
        entity: section,
        update_type: update_type,
      ).call

      section.mark_as_exported! if action != :republish
    end

    manual.removed_sections.each do |section|
      next if section.withdrawn? && action != :republish
      begin
        publishing_api_v2.unpublish(section.id, type: "redirect", alternative_path: "/#{manual.slug}", discard_drafts: true)
      rescue GdsApi::HTTPNotFound # rubocop:disable Lint/HandleExceptions
      end
      section.withdraw_and_mark_as_exported! if action != :republish
    end
  end

  def publishing_api_v2
    Services.publishing_api_v2
  end
end
{'fraction_non_alphanumeric': 0.08799617407938785, 'fraction_numerical': 0.0028694404591104736, 'mean_word_length': 3.4416135881104033, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '2651707', 'n_tokens_mistral': 646, 'n_tokens_neox': 645, 'n_words': 139}