Skip to content

Commit

Permalink
Remove placeholder logic
Browse files Browse the repository at this point in the history
Placeholder schemas were added to hold documents that were rendered by
Whitehall and not yet ready to be presented to end users.

This added some complexity to Publishing API and Content Store, as these
routes did not need to be registered with Router.

Therefore removing this logic now all rendering has been migrated out of
Whitehall.
  • Loading branch information
brucebolt committed Sep 13, 2023
1 parent a66d33b commit c5d259b
Show file tree
Hide file tree
Showing 16 changed files with 13 additions and 3,040 deletions.
8 changes: 2 additions & 6 deletions app/queries/get_content_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class GetContentCollection
:states,
)

def initialize(fields:, document_types: [], filters: {}, pagination: Pagination.new, search_query: "", search_in: nil)
def initialize(fields:, document_types: @document_types, filters: {}, pagination: Pagination.new, search_query: "", search_in: nil)
self.document_types = Array(document_types)
self.fields = (fields || default_fields) + %w[total]
self.publishing_app = filters[:publishing_app]
Expand Down Expand Up @@ -47,17 +47,13 @@ def call

def editions
scope = Edition.with_document
scope = scope.where(document_type: document_types) if document_types.any?
scope = scope.where(document_type: @document_types) if @document_types.any?
scope = scope.where(publishing_app:) if publishing_app
scope = scope.where("documents.locale": locale) unless locale == "all"
scope = Link.filter_editions(scope, link_filters) if link_filters.present?
scope
end

def document_types
@document_types.flat_map { |d| [d, "placeholder_#{d}"] }
end

def validate_fields!
return unless fields

Expand Down
8 changes: 2 additions & 6 deletions app/queries/get_linkables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ def call
attr_reader :document_type

def latest_updated_at(document_type)
non_placeholder = Edition.where(document_type:)
.maximum("updated_at")
placeholder = Edition.where(document_type: "placeholder_#{document_type}")
.maximum("updated_at")
[non_placeholder, placeholder].compact.max
Edition.where(document_type:).maximum("updated_at")
end

def linkables_query(document_type)
Edition.with_document
.where(
document_type: [document_type, "placeholder_#{document_type}"],
document_type:,
state: %w[published draft],
"documents.locale": "en",
)
Expand Down
6 changes: 0 additions & 6 deletions app/validators/schema_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ def initialize(payload:, schema: nil, schema_name: nil, schema_type: :publisher)
end

def valid?
return true if schema_name_exception?

@errors += JSON::Validator.fully_validate(
schema,
payload,
Expand Down Expand Up @@ -55,10 +53,6 @@ def schema_name
@schema_name || payload[:schema_name]
end

def schema_name_exception?
schema_name.to_s.match(/placeholder_/)
end

def missing_schema_message
"Unable to find schema for schema_name #{schema_name}"
end
Expand Down
Loading

0 comments on commit c5d259b

Please sign in to comment.