Skip to content

Commit

Permalink
Merge pull request #3173 from alphagov/mark-publications-govuk-indexable
Browse files Browse the repository at this point in the history
Mark all publication types indexable in the govuk index
  • Loading branch information
ryanb-gds authored Feb 26, 2025
2 parents ae2d927 + 5dff1db commit caf6d19
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 21 deletions.
20 changes: 20 additions & 0 deletions config/govuk_index/mapped_document_types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ case_study: edition
closed_call_for_evidence: edition
closed_consultation: edition
cma_case: cma_case # Specialist Publisher
correspondence: edition
consultation: edition
consultation_outcome: edition
contact: contact
coronavirus_landing_page: edition
corporate_report: edition
countryside_stewardship_grant: countryside_stewardship_grant # Specialist Publisher
data_ethics_guidance_document: data_ethics_guidance_document # Specialist Publisher
decision: edition
detailed_guide: edition
document_collection: edition
drcf_digital_markets_research: drcf_digital_markets_research # Specialist Publisher
Expand All @@ -33,14 +36,20 @@ export_health_certificate: export_health_certificate # Specialist Publisher
external_content: edition # Search Admin
fatality_notice: edition
finder: edition # Specialist Publisher
foi_release: edition
form: edition
government_response: edition
guidance: edition
guide: edition
help_page: edition
history: edition
hmrc_contact: hmrc_contact # Specialist Publisher
hmrc_manual: hmrc_manual
hmrc_manual_section: hmrc_manual_section
impact_assessment: edition
independent_report: edition
international_development_fund: international_development_fund # Specialist Publisher
international_treaty: edition
flood_and_coastal_erosion_risk_management_research_report: flood_and_coastal_erosion_risk_management_research_report # Specialist Publisher
farming_grant: farming_grant # Specialist Publisher
licence: edition
Expand All @@ -51,21 +60,29 @@ maib_report: maib_report # Specialist Publisher
mainstream_browse_page: edition # Collections Publisher
manual: manual
manual_section: manual_section
map: edition
marine_equipment_approved_recommendation: marine_equipment_approved_recommendation # Specialist Publisher
marine_notice: marine_notice # Specialist Publisher
medical_safety_alert: medical_safety_alert # Specialist Publisher
ministerial_role: edition
national_statistics: edition
news_story: edition
notice: edition
official_statistics: edition
oral_statement: edition # Whitehall
open_call_for_evidence: edition
open_consultation: edition
person: person
place: edition
policy: policy # Policy Publisher
policy_paper: edition
press_release: edition
product_safety_alert_report_recall: product_safety_alert_report_recall # Specialist Publisher
promotional: edition
protected_food_drink_name: protected_food_drink_name # Specialist Publisher
raib_report: raib_report # Specialist Publisher
regulation: edition
research: edition
research_for_development_output: research_for_development_output # Specialist Publisher
residential_property_tribunal_decision: residential_property_tribunal_decision # Specialist Publisher
service_manual_guide: service_manual_guide
Expand All @@ -78,16 +95,19 @@ sfo_case: sfo_case # Specialist Publisher
simple_smart_answer: edition
smart_answer: edition
statistical_data_set: edition
statutory_guidance: edition
statutory_instrument: statutory_instrument # Specialist Publisher
special_route: edition
speech: edition # Whitehall
standard: edition
step_by_step_nav: edition
traffic_commissioner_regulatory_decision: traffic_commissioner_regulatory_decision # Specialist Publisher
tax_tribunal_decision: tax_tribunal_decision # Specialist Publisher
taxon: edition # Content Tagger
topic: edition # Collections Publisher
trademark_decision: trademark_decision # Specialist Publisher
transaction: edition
transparency: edition
travel_advice: edition # Travel advice publisher
travel_advice_index: edition # Travel advice publisher
utaac_decision: utaac_decision # Specialist Publisher
Expand Down
42 changes: 21 additions & 21 deletions config/govuk_index/migrated_formats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,27 @@ migrated:
- world_news_story
- written_statement

indexable: []
indexable:
- correspondence
- corporate_report
- decision
- foi_release
- form
- guidance
- impact_assessment
- independent_report
- international_treaty
- map
- national_statistics
- notice
- official_statistics
- policy_paper
- promotional
- regulation
- research
- standard
- statutory_guidance
- transparency

non_indexable_path:
- '/help/cookie-details'
Expand Down Expand Up @@ -388,55 +408,35 @@ non_indexable:
- access_and_opening
- complaints_procedure
#- contact # migrated
- corporate_report
- correspondence
- decision
- equality_and_diversity
- facet
- field_of_operation
#- finder # migrated
- foi_release
- form
- guidance
- html_publication
- impact_assessment
- imported
- independent_report
- international_treaty
- map
- media_enquiries
- membership
- modern_slavery_statement
- national_statistics
- national_statistics_announcement
- notice
- official_statistics
- official_statistics_announcement
- organisation
- our_energy_use
- our_governance
- personal_information_charter
- petitions_and_campaigns
- policy_area
- policy_paper
- procurement
- promotional
- publication
- publication_scheme
- recruitment
- regulation
- research
- services_and_information
- social_media_use
- staff_update
- standard
- statistics
- statutory_guidance
- take_part
- terms_of_reference
- topical_event
- topical_event_about_page
- transparency
- welsh_language_scheme
- working_group
- world_location
Expand Down
12 changes: 12 additions & 0 deletions lib/govuk_index/presenters/details_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ def end_date
details["closing_date"]
end

def has_official_document?
has_command_paper? || has_act_paper?
end

def has_command_paper?
details["attachments"]&.any? { |attachment| attachment["command_paper_number"].present? || attachment["unnumbered_command_paper"] }
end

def has_act_paper?
details["attachments"]&.any? { |attachment| attachment["hoc_paper_number"].present? || attachment["unnumbered_hoc_paper"] }
end

private

def service_manual
Expand Down
3 changes: 3 additions & 0 deletions lib/govuk_index/presenters/elasticsearch_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def document
government_document_supertype: common_fields.government_document_supertype,
government_name: common_fields.government_name,
grant_type: specialist.grant_type,
has_act_paper: details.has_act_paper?,
has_command_paper: details.has_command_paper?,
has_official_document: details.has_official_document?,
hidden_indexable_content: specialist.hidden_indexable_content,
hmrc_manual_section_id: common_fields.section_id,
image_url:,
Expand Down
137 changes: 137 additions & 0 deletions spec/unit/govuk_index/presenters/details_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,141 @@
end
end
end

context "publication format" do
let(:format) { "publication" }
context "it has an attachment with a command paper number" do
let(:details) do
{
"attachments" => [
{
"command_paper_number" => "Cm. 1234",
},
],
}
end

it "has an official document" do
expect(presented_details.has_official_document?).to be true
end

it "has a command paper" do
expect(presented_details.has_command_paper?).to be true
end

it "does not have an act paper" do
expect(presented_details.has_act_paper?).to be false
end
end

context "it has an attachment that is an unnumbered command paper" do
let(:details) do
{
"attachments" => [
{
"unnumbered_command_paper" => true,
},
],
}
end

it "has an official document" do
expect(presented_details.has_official_document?).to be true
end

it "has a command paper" do
expect(presented_details.has_command_paper?).to be true
end

it "does not have an act paper" do
expect(presented_details.has_act_paper?).to be false
end
end

context "it has an attachment with an hoc paper number" do
let(:details) do
{
"attachments" => [
{
"hoc_paper_number" => "Hoc. 1234",
},
],
}
end

it "has an official document" do
expect(presented_details.has_official_document?).to be true
end

it "does not have a command paper" do
expect(presented_details.has_command_paper?).to be false
end

it "has an act paper" do
expect(presented_details.has_act_paper?).to be true
end
end

context "it has an attachment that is an unnumbered hoc paper" do
let(:details) do
{
"attachments" => [
{
"unnumbered_hoc_paper" => true,
},
],
}
end

it "has an official document" do
expect(presented_details.has_official_document?).to be true
end

it "does not have a command paper" do
expect(presented_details.has_command_paper?).to be false
end

it "has an act paper" do
expect(presented_details.has_act_paper?).to be true
end
end

context "it has no attachments that are hoc papers or command papers" do
let(:details) do
{
"attachments" => [],
}
end

it "has an official document" do
expect(presented_details.has_official_document?).to be false
end

it "does not have a command paper" do
expect(presented_details.has_command_paper?).to be false
end

it "has an act paper" do
expect(presented_details.has_act_paper?).to be false
end
end

context "it has no attachments" do
let(:details) do
{}
end

it "has an official document" do
expect(presented_details.has_official_document?).to be nil
end

it "does not have a command paper" do
expect(presented_details.has_command_paper?).to be nil
end

it "has an act paper" do
expect(presented_details.has_act_paper?).to be nil
end
end
end
end

0 comments on commit caf6d19

Please sign in to comment.