From 54a1ca8de8e1bd2a8e6307e1cbe3b79ecaeca30e Mon Sep 17 00:00:00 2001 From: Emma Date: Tue, 28 Apr 2026 18:27:16 +0100 Subject: [PATCH] Delete publishing_api_finder_publisher.rb Classes in this file are no longer referenced in search-api and can be removed. They used to be used in a rake task that published the "advanced search finder" until this was updated to be published in the same way as other finders [1][2]. The deprecated rake task used a class called PublishingApiFinderPublisher that was removed [3] but the other classes in this file that PublishingApiFinderPublisher referenced were not deleted at that time. This is overdue clean up. [1] https://github.com/alphagov/search-api/pull/1492 [2] https://github.com/alphagov/search-api/blob/main/lib/tasks/publishing_api.rake#L10 [3] https://github.com/alphagov/search-api/pull/1967 --- lib/publishing_api_finder_publisher.rb | 106 ------------------------- lib/tasks/publishing_api.rake | 2 - 2 files changed, 108 deletions(-) delete mode 100644 lib/publishing_api_finder_publisher.rb diff --git a/lib/publishing_api_finder_publisher.rb b/lib/publishing_api_finder_publisher.rb deleted file mode 100644 index 3b572d079..000000000 --- a/lib/publishing_api_finder_publisher.rb +++ /dev/null @@ -1,106 +0,0 @@ -require "gds_api/publishing_api" -require "govuk_schemas" - -class FinderContentItemPresenter - attr_reader :content_id, :schema, :name, :timestamp - - def initialize(schema, timestamp) - @schema = schema - @content_id = schema["content_id"] - @name = schema["name"] - @timestamp = timestamp - end - - def present - { - base_path: schema["base_path"], - description: schema["description"], - details:, - document_type: schema["document_type"], - locale: "en", - phase: "live", - public_updated_at: timestamp, - publishing_app: schema["publishing_app"], - rendering_app: schema["rendering_app"], - routes: schema["routes"], - schema_name: schema["schema_name"], - title: schema["title"], - update_type: "minor", - } - end - - def present_links - links = {} - links["email_alert_signup"] = [schema["signup_content_id"]] if schema.key?("signup_content_id") - links["parent"] = Array(schema["parent"]) if schema.key?("parent") - links["ordered_related_items"] = Array(schema["ordered_related_items"]) if schema.key?("ordered_related_items") - - { content_id:, links: } - end - - def details - schema["details"].except("email_filter_facets", "subscription_list_title_prefix") - end -end - -class FinderEmailSignupContentItemPresenter - attr_reader :content_id, :schema, :name, :timestamp - - def initialize(schema, timestamp) - @schema = schema - @content_id = schema["signup_content_id"] - @name = schema["name"] - @timestamp = timestamp - end - - def details - details = schema.fetch("details", {}) - - # First ensure we're removing any surplus fields so we match the schema - details.slice(GovukSchemas::Schema.find(publisher_schema: "finder_email_signup")) - .merge( - "subscription_list_title_prefix" => details.fetch("subscription_list_title_prefix", {}), - "email_filter_facets" => email_filter_facets, - ) - end - - def present - path = "#{schema['base_path']}/email-signup" - { - base_path: path, - description: schema["signup_copy"], - details:, - document_type: "finder_email_signup", - locale: "en", - phase: "live", - public_updated_at: timestamp, - publishing_app: schema["publishing_app"], - rendering_app: schema["rendering_app"], - routes: [{ "type" => "exact", "path" => path }], - schema_name: "finder_email_signup", - title: schema.fetch("signup_title", schema.fetch("name")), - update_type: "minor", - } - end - - def present_links - { content_id:, links: {} } - end - - def email_filter_facets - schema["details"]["facets"].map do |facet| - { - "facet_id" => facet["key"], - "facet_name" => facet["name"], - "facet_choices" => facet["allowed_values"].map do |av| - { - "key" => av["value"], - "radio_button_name" => av["label"], - "topic_name" => av["label"], - "prechecked" => false, - } - end, - } - end - end -end diff --git a/lib/tasks/publishing_api.rake b/lib/tasks/publishing_api.rake index 1bf2ab3ac..924eb6798 100644 --- a/lib/tasks/publishing_api.rake +++ b/lib/tasks/publishing_api.rake @@ -1,5 +1,3 @@ -require "publishing_api_finder_publisher" - namespace :publishing_api do desc " Publish finder and email signup content items