Skip to content

Commit

Permalink
Merge pull request #2998 from alphagov/content-modelling/659-return-c…
Browse files Browse the repository at this point in the history
…ontent-id-on-hosts

add content id to host documents
  • Loading branch information
Harriethw authored Nov 25, 2024
2 parents 5ad4297 + 0793fcc commit 751fde8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/presenters/embedded_content_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def results
last_edited_at: edition.last_edited_at,
unique_pageviews: edition.unique_pageviews,
instances: edition.instances,
host_content_id: edition.host_content_id,
primary_publishing_organisation: {
content_id: edition.primary_publishing_organisation_content_id,
title: edition.primary_publishing_organisation_title,
Expand Down
2 changes: 2 additions & 0 deletions app/queries/get_embedded_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class GetEmbeddedContent
:publishing_app,
:last_edited_by_editor_id,
:last_edited_at,
:host_content_id,
:primary_publishing_organisation_content_id,
:primary_publishing_organisation_title,
:primary_publishing_organisation_base_path,
Expand Down Expand Up @@ -39,6 +40,7 @@ class GetEmbeddedContent
{ field: TABLES[:org_editions][:title], alias: "primary_publishing_organisation_title", included_in_group?: true },
{ field: TABLES[:org_editions][:base_path], alias: "primary_publishing_organisation_base_path", included_in_group?: true },
{ field: TABLES[:statistics_caches][:unique_pageviews], included_in_group?: true },
{ field: TABLES[:documents][:content_id], alias: "host_content_id", included_in_group?: true },
{ field: TABLES[:editions][:id].count, alias: "instances", included_in_group?: false },
].freeze

Expand Down
1 change: 1 addition & 0 deletions spec/integration/embedded_content_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"last_edited_at" => last_edited_at,
"unique_pageviews" => statistics_cache.unique_pageviews,
"instances" => 1,
"host_content_id" => host_edition.content_id,
"primary_publishing_organisation" => {
"content_id" => publishing_organisation.content_id,
"title" => publishing_organisation.title,
Expand Down
3 changes: 3 additions & 0 deletions spec/presenters/embedded_content_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
let(:organisation_edition_id) { SecureRandom.uuid }
let(:target_edition_id) { SecureRandom.uuid }
let(:last_edited_by_editor_id) { SecureRandom.uuid }
let(:host_content_id) { SecureRandom.uuid }
let(:last_edited_at) { 2.days.ago }
let(:total) { 222 }
let(:total_pages) { 23 }
Expand All @@ -17,6 +18,7 @@
last_edited_by_editor_id:,
last_edited_at:,
unique_pageviews: 123,
host_content_id:,
primary_publishing_organisation_content_id: organisation_edition_id,
primary_publishing_organisation_title: "bar",
primary_publishing_organisation_base_path: "/bar",
Expand All @@ -40,6 +42,7 @@
last_edited_at:,
unique_pageviews: 123,
instances: 1,
host_content_id: host_content_id,
primary_publishing_organisation: {
content_id: organisation_edition_id,
title: "bar",
Expand Down
1 change: 1 addition & 0 deletions spec/queries/get_embedded_content_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
expect(results[i].base_path).to eq(host_edition.base_path)
expect(results[i].document_type).to eq(host_edition.document_type)
expect(results[i].publishing_app).to eq(host_edition.publishing_app)
expect(results[i].host_content_id).to eq(host_edition.content_id)
expect(results[i].primary_publishing_organisation_content_id).to eq(organisation.content_id)
expect(results[i].primary_publishing_organisation_title).to eq(organisation.title)
expect(results[i].primary_publishing_organisation_base_path).to eq(organisation.base_path)
Expand Down

0 comments on commit 751fde8

Please sign in to comment.