<commit_before>module SyncChecker::Formats
  class ConsultationCheck < EditionBase
    def expected_details_hash(consultation)
      super.tap do |details|
        details.except!(:change_history) unless consultation.change_history.present?
        details.merge!(expected_documents(consultation))
      end
    end

    def rendering_app
      Whitehall::RenderingApp::WHITEHALL_FRONTEND
    end

    def root_path
      '/government/consultations/'
    end

  private

    LENGTH_OF_FRACTIONAL_SECONDS = 3

    def expected_documents(consultation)
      return {} unless consultation.attachments.present?

      {
        documents: Whitehall::GovspeakRenderer.new.block_attachments(
          consultation.attachments,
          consultation.alternative_format_contact_email
        )
      }
    end

    def first_public_at(consultation)
      (consultation.first_published_at || consultation.document.created_at)
        .to_datetime
        .rfc3339(LENGTH_OF_FRACTIONAL_SECONDS)
    end
<commit_msg>Consultation external URL sync check<commit_after>module SyncChecker::Formats
  class ConsultationCheck < EditionBase
    def expected_details_hash(consultation)
      super.tap do |details|
        details.except!(:change_history) unless consultation.change_history.present?
        details.merge!(expected_documents(consultation))
        details.merge!(expected_external_url(consultation))
      end
    end

    def rendering_app
      Whitehall::RenderingApp::WHITEHALL_FRONTEND
    end

    def root_path
      '/government/consultations/'
    end

  private

    LENGTH_OF_FRACTIONAL_SECONDS = 3

    def expected_documents(consultation)
      return {} unless consultation.attachments.present?

      {
        documents: Whitehall::GovspeakRenderer.new.block_attachments(
          consultation.attachments,
          consultation.alternative_format_contact_email
        )
      }
    end

    def expected_external_url(consultation)
      return {} unless consultation.external?

      { held_on_another_website_url: consultation.external_url }
    end

    def first_public_at(consultation)
      (consultation.first_published_at || consultation.document.created_at)
        .to_datetime
        .rfc3339(LENGTH_OF_FRACTIONAL_SECONDS)
    end

{'fraction_non_alphanumeric': 0.06631299734748011, 'fraction_numerical': 0.004420866489832007, 'mean_word_length': 3.2537593984962405, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2642500', 'n_tokens_mistral': 673, 'n_tokens_neox': 652, 'n_words': 101}