<commit_before>require 'gds_api/publishing_api'
require 'gds_api/publishing_api/special_route_publisher'

class SpecialRoutePublisher
  def initialize(publisher_options)
    @publisher = GdsApi::PublishingApi::SpecialRoutePublisher.new(publisher_options)
  end

  def take_ownership_of_search_routes
    publishing_api_v1 = GdsApi::PublishingApi.new(
      Plek.new.find('publishing-api'),
      bearer_token: ENV['PUBLISHING_API_BEARER_TOKEN'] || 'example'
    )
    %w(/search /search.json /search/opensearch.xml).each do |path|
      publishing_api_v1.put_path(
        path,
        publishing_app: 'rummager',
        override_existing: true
      )
    end
  end

  def publish(route)
    @publisher.publish(
      route.merge(
        publishing_app: "rummager",
        format: "special_route",
        public_updated_at: Time.now.iso8601,
        update_type: "major",
      )
    )
  end

  def routes
    [
      {
        rendering_app: "finder-frontend",
        content_id: "84e0909c-f3e6-43ee-ba68-9e33213a3cdd",
        base_path: "/search",
        title: "GOV.UK search results",
        description: "Sitewide search results are displayed here.",
        document_type: "search",
        type: "exact",
      },
      {
        rendering_app: "finder-frontend",
        content_id: "9f306cd5-1842-43e9-8408-2c13116f4717",
        base_path: "/search.json",
        title: "GOV.UK search results API",
        description: "Sitewide search results are displayed in JSON format here.",
        type: "exact",
      },
      {
        rendering_app: "finder-frontend",
        content_id: "ba750368-8001-4d01-bd57-cec589153fdd",
        base_path: "/search/opensearch.xml",
        title: "GOV.UK opensearch descriptor",
        description: "Provides the location and format of our search URL to browsers etc.",
        type: "exact",
      },
      {
        rendering_app: "rummager",
        base_path: "/sitemap.xml",
        content_id: "fee32a90-397a-4761-9f98-b06e47d2b798",
        title: "GOV.UK sitemap index",
        description: "Provides the locations of the GOV.UK sitemaps.",
        type: "exact",
      },
      {
        rendering_app: "rummager",
        base_path: "/sitemaps",
        content_id: "c202c6a5-656c-40d1-ae55-36fab995709c",
        title: "GOV.UK sitemaps prefix",
        description: "The prefix URL under which our XML sitemaps are located.",
        type: "prefix",
      }
    ]
  end
end<commit_msg>Add finder-frontend Q&A publish route<commit_after>require 'gds_api/publishing_api'
require 'gds_api/publishing_api/special_route_publisher'

class SpecialRoutePublisher
  def initialize(publisher_options)
    @publisher = GdsApi::PublishingApi::SpecialRoutePublisher.new(publisher_options)
  end

  def take_ownership_of_search_routes
    publishing_api_v1 = GdsApi::PublishingApi.new(
      Plek.new.find('publishing-api'),
      bearer_token: ENV['PUBLISHING_API_BEARER_TOKEN'] || 'example'
    )
    %w(/search /search.json /search/opensearch.xml).each do |path|
      publishing_api_v1.put_path(
        path,
        publishing_app: 'rummager',
        override_existing: true
      )
    end
  end

  def publish(route)
    @publisher.publish(
      route.merge(
        publishing_app: "rummager",
        format: "special_route",
        public_updated_at: Time.now.iso8601,
        update_type: "major",
      )
    )
  end

  def routes
    [
      {
        rendering_app: "finder-frontend",
        content_id: "84e0909c-f3e6-43ee-ba68-9e33213a3cdd",
        base_path: "/search",
        title: "GOV.UK search results",
        description: "Sitewide search results are displayed here.",
        document_type: "search",
        type: "exact",
      },
      {
        rendering_app: "finder-frontend",
        content_id: "9f306cd5-1842-43e9-8408-2c13116f4717",
        base_path: "/search.json",
        title: "GOV.UK search results API",
        description: "Sitewide search results are displayed in JSON format here.",
        type: "exact",
      },
      {
        rendering_app: "finder-frontend",
        content_id: "ba750368-8001-4d01-bd57-cec589153fdd",
        base_path: "/search/opensearch.xml",
        title: "GOV.UK opensearch descriptor",
        description: "Provides the location and format of our search URL to browsers etc.",
        type: "exact",
      },
      {
        rendering_app: "rummager",
        base_path: "/sitemap.xml",
        content_id: "fee32a90-397a-4761-9f98-b06e47d2b798",
        title: "GOV.UK sitemap index",
        description: "Provides the locations of the GOV.UK sitemaps.",
        type: "exact",
      },
      {
        rendering_app: "rummager",
        base_path: "/sitemaps",
        content_id: "c202c6a5-656c-40d1-ae55-36fab995709c",
        title: "GOV.UK sitemaps prefix",
        description: "The prefix URL under which our XML sitemaps are located.",
        type: "prefix",
      },
      {
        rendering_app: "finder-frontend",
        base_path: "/prepare-business-uk-leaving-eu",
        content_id: "b9ef4434-761f-49ae-af97-dc7a248499c4",
        title: "Prepare your business for the UK leaving the EU",
        description: "Q&A frontend for the 'Find EU Exit guidance for your business' finder",
        type: "exact",
      }
    ]
  end
end
{'fraction_non_alphanumeric': 0.11106913486966377, 'fraction_numerical': 0.04722327162825841, 'mean_word_length': 2.5182724252491693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '946287', 'n_tokens_mistral': 1906, 'n_tokens_neox': 1773, 'n_words': 356}