Skip to content

Commit

Permalink
Merge pull request #272 from alphagov/public-ts-datetime
Browse files Browse the repository at this point in the history
Populate `public_timestamp_datetime` metadata field
  • Loading branch information
csutter committed May 16, 2024
2 parents 14871f9 + 41e4749 commit 6b1f20a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/concerns/publishing_api/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def metadata
link:,
url:,
public_timestamp:,
public_timestamp_datetime: document_hash[:public_updated_at],
document_type: document_hash[:document_type],
content_purpose_supergroup: document_hash[:content_purpose_supergroup],
part_of_taxonomy_tree:,
Expand Down
13 changes: 13 additions & 0 deletions spec/integration/document_synchronization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
link: "/government/news/uk-and-japan-strengthen-cooperation-in-the-area-of-digital-government",
url: "https://www.gov.uk/government/news/uk-and-japan-strengthen-cooperation-in-the-area-of-digital-government",
public_timestamp: 1_667_217_614,
public_timestamp_datetime: "2022-10-31T12:00:14Z",
document_type: "press_release",
is_historic: 0,
government_name: "2015 Conservative government",
Expand Down Expand Up @@ -62,6 +63,7 @@
link: "/foreign-travel-advice/austria",
url: "https://www.gov.uk/foreign-travel-advice/austria",
public_timestamp: 1_697_629_071,
public_timestamp_datetime: "2023-10-18T11:37:51Z",
document_type: "travel_advice",
is_historic: 0,
content_purpose_supergroup: "guidance_and_regulation",
Expand Down Expand Up @@ -124,6 +126,7 @@
link: "/government/news/travel-advice-for-fans-going-to-champions-league-and-europa-league-matches-this-week",
url: "https://www.gov.uk/government/news/travel-advice-for-fans-going-to-champions-league-and-europa-league-matches-this-week",
public_timestamp: 1_284_336_000,
public_timestamp_datetime: "2010-09-13T00:00:00Z",
document_type: "news_story",
is_historic: 1,
government_name: "2010 to 2015 Conservative and Liberal Democrat coalition government",
Expand Down Expand Up @@ -161,6 +164,7 @@
link: "/guidance/mot-inspection-manual-for-private-passenger-and-light-commercial-vehicles/6-body-structure-and-attachments",
url: "https://www.gov.uk/guidance/mot-inspection-manual-for-private-passenger-and-light-commercial-vehicles/6-body-structure-and-attachments",
public_timestamp: 1_646_221_134,
public_timestamp_datetime: "2022-03-02T11:38:54Z",
document_type: "manual_section",
is_historic: 0,
content_purpose_supergroup: "guidance_and_regulation",
Expand Down Expand Up @@ -190,6 +194,7 @@
link: "/hmrc-internal-manuals/business-income-manual/bim60660",
url: "https://www.gov.uk/hmrc-internal-manuals/business-income-manual/bim60660",
public_timestamp: 1_485_643_092,
public_timestamp_datetime: "2017-01-28T22:38:12Z",
document_type: "hmrc_manual_section",
is_historic: 0,
content_purpose_supergroup: "other",
Expand Down Expand Up @@ -220,6 +225,7 @@
link: "/service-manual/service-standard/point-5-make-sure-everyone-can-use-the-service",
url: "https://www.gov.uk/service-manual/service-standard/point-5-make-sure-everyone-can-use-the-service",
public_timestamp: 1_653_906_028,
public_timestamp_datetime: "2022-05-30T10:20:28Z",
document_type: "service_manual_guide",
is_historic: 0,
content_purpose_supergroup: "other",
Expand Down Expand Up @@ -250,6 +256,7 @@
link: "/government/organisations/legal-aid-agency",
url: "https://www.gov.uk/government/organisations/legal-aid-agency",
public_timestamp: 1_695_391_634,
public_timestamp_datetime: "2023-09-22T14:07:14Z",
document_type: "organisation",
is_historic: 0,
organisation_state: "live",
Expand Down Expand Up @@ -280,6 +287,7 @@
link: "/world/organisations/british-embassy-vienna",
url: "https://www.gov.uk/world/organisations/british-embassy-vienna",
public_timestamp: 1_372_436_926,
public_timestamp_datetime: "2013-06-28T16:28:46Z",
document_type: "worldwide_organisation",
is_historic: 0,
part_of_taxonomy_tree: an_array_matching(%w[
Expand Down Expand Up @@ -315,6 +323,7 @@
link: "/government/publications/directgov-2010-and-beyond-revolution-not-evolution-a-report-by-martha-lane-fox",
url: "https://www.gov.uk/government/publications/directgov-2010-and-beyond-revolution-not-evolution-a-report-by-martha-lane-fox",
public_timestamp: 1_290_470_400,
public_timestamp_datetime: "2010-11-23T00:00:00Z",
document_type: "independent_report",
is_historic: 0,
government_name: "2010 to 2015 Conservative and Liberal Democrat coalition government",
Expand Down Expand Up @@ -358,6 +367,7 @@
link: "/world/switzerland",
url: "https://www.gov.uk/world/switzerland",
public_timestamp: 1_583_165_036,
public_timestamp_datetime: "2020-03-02T16:03:56Z",
document_type: "taxon",
is_historic: 0,
content_purpose_supergroup: "other",
Expand Down Expand Up @@ -389,6 +399,7 @@
link: "/government/speeches/a-service-of-thanksgiving-for-the-life-of-her-majesty-queen-elizabeth-ii-at-the-washington-national-cathedral",
url: "https://www.gov.uk/government/speeches/a-service-of-thanksgiving-for-the-life-of-her-majesty-queen-elizabeth-ii-at-the-washington-national-cathedral",
public_timestamp: 1_663_794_900,
public_timestamp_datetime: "2022-09-21T21:15:00Z",
government_name: "2015 Conservative government",
organisations: %w[foreign-commonwealth-development-office],
document_type: "speech",
Expand Down Expand Up @@ -430,6 +441,7 @@
locale: "en",
organisations: %w[ofqual],
public_timestamp: 1_663_851_889,
public_timestamp_datetime: "2022-09-22T13:04:49Z",
title: "Access Consultation Forum terms of reference",
url: "https://www.gov.uk/government/publications/access-consultation-forum-terms-of-reference/access-consultation-forum-terms-of-reference",
},
Expand All @@ -452,6 +464,7 @@
link: "https://www.brighton-hove.gov.uk",
url: "https://www.brighton-hove.gov.uk",
public_timestamp: 1_695_912_979,
public_timestamp_datetime: "2023-09-28T14:56:19Z",
document_type: "external_content",
is_historic: 0,
content_purpose_supergroup: "other",
Expand Down
14 changes: 14 additions & 0 deletions spec/models/concerns/publishing_api/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@
end
end

describe "public_timestamp_datetime" do
subject(:extracted_public_timestamp_datetime) { extracted_metadata[:public_timestamp_datetime] }

let(:document_hash) { { public_updated_at: "2012-02-01T00:00:00Z" } }

it { is_expected.to eq("2012-02-01T00:00:00Z") }

context "without a public_timestamp" do
let(:document_hash) { {} }

it { is_expected.to be_nil }
end
end

describe "document_type" do
subject(:extracted_document_type) { extracted_metadata[:document_type] }

Expand Down

0 comments on commit 6b1f20a

Please sign in to comment.