Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduled publishing and fix differences from content-store #27

Merged
merged 6 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions app/controllers/content_store_shim_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ def compare_content_item
if edition.nil?
render json: { error: "Not found" }, status: :not_found
else
graphql_content_item = get_graphql_content_item(edition, base_path)
content_store_content_item = GdsApi.content_store.content_item(base_path).to_h
diff = Hashdiff.diff(content_store_content_item, graphql_content_item)
graphql_content_item = sort_links(get_graphql_content_item(edition, base_path))
content_store_content_item = sort_links(GdsApi.content_store.content_item(base_path).to_h)
diff = Hashdiff.diff(
content_store_content_item,
graphql_content_item,
similarity: 0.5,
ignore_keys: %w[public_updated_at],
) do |_path, left, right|
# If both sides are blank, consider them equal (even though they might be null, "" or {} etc.)
true if left.blank? && right.blank?
end
render json: {
diff:,
graphql_content_item:,
Expand All @@ -44,4 +52,18 @@ def get_graphql_content_item(edition, base_path)
result.dig("data", "edition")
end
end

def sort_links(input)
return unless input.is_a?(Hash)

links = input["links"]
return unless links.is_a?(Hash)

links.each_value do |arr|
arr&.each { sort_links(it) }
arr&.sort_by! { it["base_path"] }
end

input
end
end
2 changes: 2 additions & 0 deletions app/graphql/queries/answer.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ query answer($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/calendar.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ query calendar($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/call_for_evidence.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ query call_for_evidence($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/case_study.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ query case_study($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/completed_transaction.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ query completed_transaction($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/consultation.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ query consultation($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/contact.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ query contact($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/coronavirus_landing_page.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ query coronavirus_landing_page($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/corporate_information_page.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ query corporate_information_page($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/detailed_guide.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ query detailed_guide($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/document_collection.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ query document_collection($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/email_alert_signup.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ query email_alert_signup($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/embassies_index.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ query embassies_index($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/fatality_notice.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ query fatality_notice($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/field_of_operation.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ query field_of_operation($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/fields_of_operation.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ query fields_of_operation($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/finder.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ query finder($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/finder_email_signup.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ query finder_email_signup($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/generic.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ query generic($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/get_involved.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ query get_involved($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/government.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ query government($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/guide.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ query guide($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/help_page.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ query help_page($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/historic_appointment.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ query historic_appointment($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/historic_appointments.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ query historic_appointments($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/history.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ query history($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/hmrc_manual.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ query hmrc_manual($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/hmrc_manual_section.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ query hmrc_manual_section($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
3 changes: 3 additions & 0 deletions app/graphql/queries/homepage.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ query homepage($base_path: String!) {
api_url
base_path
content_id
description
details {
internal_name
notes_for_editors
Expand Down Expand Up @@ -112,7 +113,9 @@ query homepage($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/how_government_works.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ query how_government_works($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/landing_page.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ query landing_page($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/local_transaction.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ query local_transaction($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/mainstream_browse_page.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ query mainstream_browse_page($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/manual.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ query manual($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/queries/manual_section.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ query manual_section($base_path: String!) {
public_updated_at
publishing_app
publishing_request_id
publishing_scheduled_at
rendering_app
scheduled_publishing_delay_seconds
schema_name
title
updated_at
Expand Down
Loading