Skip to content
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
2 changes: 2 additions & 0 deletions app/lib/registries/registry.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Registries
class Registry
NAMESPACE = "registries".freeze

def can_refresh_cache?
false
end
Expand Down
113 changes: 104 additions & 9 deletions app/lib/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,115 @@
require "gds_api/email_alert_api"

module Services
ALLOWED_LOCAL_CONTENT = %w[
_
_aaib-reports
_administrative-appeals-tribunal-decisions
_ai-assurance-techniques
_algorithmic-transparency-records
_animal-disease-cases-england
_armed-forces-covenant-businesses
_asylum-support-tribunal-decisions
_business-and-industry
_business-finance-support
_capital-grant-finder
_childcare-parenting
_cma-cases
_corporate-information
_crime-justice-and-law
_data-access-approvals-register
_data-ethics-guidance
_defence-and-armed-forces
_designs-decisions
_drug-device-alerts
_drug-safety-update
_education
_employment-appeal-tribunal-decisions
_employment-tribunal-decisions
_entering-staying-uk
_environment
_eu-withdrawal-act-2018-statutory-instruments
_european-structural-investment-funds
_export-health-certificates
_find-digital-market-research
_find-funding-for-land-or-farms
_find-hmrc-contacts
_find-hmrc-manuals
_find-licences
_flood-and-coastal-erosion-risk-management-research-reports
_going-and-being-abroad
_government_all
_government_case-studies
_government_groups
_government_people
_government_statistical-data-sets
_health-and-social-care
_housing-local-and-community
_international-development-funding
_international
_life-circumstances
_maib-reports
_marine-equipment-approved-recommendations
_money
_official-documents
_product-safety-alerts-reports-recalls
_protected-food-drink-names
_raib-reports
_regional-and-local-government
_research-for-development-outputs
_residential-property-tribunal-decisions
_search
_search_all
_search_guidance-and-regulation
_search_news-and-communications
_search_policy-papers-and-consultations
_search_research-and-statistics
_search_services
_search_transparency-and-freedom-of-information-releases
_service-life-saving-maritime-appliances
_service-standard-reports
_sfo-cases
_society-and-culture
_support-for-veterans
_tax-and-chancery-tribunal-decisions
_traffic-commissioner-regulatory-decisions
_transport
_welfare
_work
_world
_world_organisations
].freeze

# The filenames of the local files are the paths of the content items with "/" converted to "_"
# _.json is the content item for the home page (used for taxons)
# _search_all is the content item for /search/all, etc
def self.filename_from_path(path)
path_overrides = { "" => "_" }
path_overrides[path] || path.gsub("/", "_")
end

def self.content_store
GdsApi::ContentStore.new(Plek.find("content-store"))
end

def self.cached_content_item(base_path)
Rails.cache.fetch("finder-frontend_content_items#{base_path}", expires_in: 5.minutes) do
GovukStatsd.time("content_store.fetch_request_time") do
content_item = content_store.content_item(base_path)
content_item_hash = content_item.to_h
content_item_hash["cache_control"] = {
"max_age" => content_item.cache_control["max-age"],
"public" => !content_item.cache_control.private?,
}
content_item_hash
filename = filename_from_path(base_path)

if ALLOWED_LOCAL_CONTENT.include?(filename)
GovukStatsd.time("file_store.fetch_request_time") do
JSON.parse(File.read(Rails.root.join("config/local_content/#{filename}.json")))
end
else
Rails.cache.fetch("finder-frontend_content_items#{base_path}", expires_in: 5.minutes) do
GovukStatsd.time("content_store.fetch_request_time") do
content_item = content_store.content_item(base_path)
content_item_hash = content_item.to_h
content_item_hash["cache_control"] = {
"max_age" => content_item.cache_control["max-age"],
"public" => !content_item.cache_control.private?,
}
content_item_hash
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions config/local_content/_.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions config/local_content/_aaib-reports.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"analytics_identifier":null,"base_path":"/aaib-reports","content_id":"b7574bba-969f-4c49-855a-ae1586258ff6","description":"Find reports of AAIB investigations into air accidents and incidents","details":{"default_documents_per_page":50,"document_noun":"report","facets":[{"allowed_values":[{"label":"Commercial - fixed wing","value":"commercial-fixed-wing"},{"label":"Commercial - rotorcraft","value":"commercial-rotorcraft"},{"label":"General aviation - fixed wing","value":"general-aviation-fixed-wing"},{"label":"General aviation - rotorcraft","value":"general-aviation-rotorcraft"},{"label":"Spaceflight","value":"spaceflight"},{"label":"Sport aviation and balloons","value":"sport-aviation-and-balloons"},{"label":"Unmanned Aircraft Systems (UAS)","value":"unmanned-aircraft-systems"}],"display_as_result_metadata":true,"filterable":true,"key":"aircraft_category","name":"Category","preposition":"in category","type":"text"},{"allowed_values":[{"label":"Annual safety report","value":"annual-safety-report"},{"label":"Bulletin - Correspondence investigation","value":"correspondence-investigation"},{"label":"Bulletin - Field investigation","value":"field-investigation"},{"label":"Bulletin - Pre-1997 uncategorised monthly report","value":"pre-1997-monthly-report"},{"label":"Foreign report","value":"foreign-report"},{"label":"Formal report","value":"formal-report"},{"label":"Spaceflight","value":"spaceflight"},{"label":"Special bulletin","value":"special-bulletin"},{"label":"Safety study","value":"safety-study"}],"display_as_result_metadata":true,"filterable":true,"key":"report_type","name":"Report type","preposition":"of type","type":"text"},{"display_as_result_metadata":true,"filterable":true,"key":"date_of_occurrence","name":"Date of occurrence","preposition":"occurred","short_name":"Occurred","type":"date"},{"display_as_result_metadata":false,"filterable":false,"key":"aircraft_type","name":"Aircraft type","type":"text"},{"display_as_result_metadata":false,"filterable":false,"key":"location","name":"Location","type":"text"},{"display_as_result_metadata":false,"filterable":false,"key":"registration","name":"Registration","type":"text"}],"filter":{"format":"aaib_report"},"show_metadata_block":true,"show_summaries":true,"show_table_of_contents":true},"document_type":"finder","first_published_at":"2015-09-03T15:47:48+01:00","links":{"available_translations":[{"api_path":"/api/content/aaib-reports","api_url":"https://www.gov.uk/api/content/aaib-reports","base_path":"/aaib-reports","content_id":"b7574bba-969f-4c49-855a-ae1586258ff6","document_type":"finder","links":{},"locale":"en","public_updated_at":"2025-04-28T18:53:05Z","schema_name":"finder","title":"Air Accidents Investigation Branch reports","web_url":"https://www.gov.uk/aaib-reports","withdrawn":false}],"organisations":[{"analytics_identifier":"OT248","api_path":"/api/content/government/organisations/air-accidents-investigation-branch","api_url":"https://www.gov.uk/api/content/government/organisations/air-accidents-investigation-branch","base_path":"/government/organisations/air-accidents-investigation-branch","content_id":"38eb5d8f-2d89-480c-8655-e2e7ac23f8f4","details":{"acronym":"AAIB","brand":"department-for-transport","default_news_image":{"high_resolution_url":"https://assets.publishing.service.gov.uk/media/5a37db2240f0b649cceb18ad/s960_AAIB_Default_News_Image.jpg","url":"https://assets.publishing.service.gov.uk/media/5a37db23e5274a79051c9260/s300_AAIB_Default_News_Image.jpg"},"logo":{"crest":"custom","formatted_title":"Air Accidents\u003cbr/\u003eInvestigation Branch","image":{"alt_text":"Air Accidents Investigation Branch","url":"https://assets.publishing.service.gov.uk/media/6751c5542086e98fae3511a9/AAIB_logo_black_-_transparent_background_960_px_640_px.png"}},"organisation_govuk_status":{"status":"live","updated_at":null,"url":null}},"document_type":"organisation","links":{},"locale":"en","schema_name":"organisation","title":"Air Accidents Investigation Branch","web_url":"https://www.gov.uk/government/organisations/air-accidents-investigation-branch","withdrawn":false}]},"locale":"en","phase":"live","public_updated_at":"2025-04-28T19:53:05+01:00","publishing_app":"specialist-publisher","publishing_request_id":"21-1745867267.641-10.13.35.92-695","publishing_scheduled_at":null,"rendering_app":"finder-frontend","scheduled_publishing_delay_seconds":null,"schema_name":"finder","title":"Air Accidents Investigation Branch reports","updated_at":"2025-12-10T10:55:51+00:00","withdrawn_notice":{}}

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions config/local_content/_ai-assurance-techniques.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"analytics_identifier":null,"base_path":"/ai-assurance-techniques","content_id":"5e5890a0-329a-42d2-9637-9d8433fe97ae","description":"Find out what AI assurance is and what AI assurance techniques you can use in your organisation.","details":{"default_documents_per_page":50,"document_noun":"case study","facets":[{"allowed_values":[{"label":"Big data analytics","value":"big-data-analytics"},{"label":"Data-driven profiling","value":"data-driven-profiling"},{"label":"Natural language processing and generation","value":"natural-language-processing-and-generation"},{"label":"Image recognition and video processing","value":"image-recognition-and-video-processing"},{"label":"Machine learning","value":"machine-learning"},{"label":"Deep learning","value":"deep-learning"},{"label":"Virtual agents or artificial conversational interfaces","value":"virtual-agents-or-artificial-conversational-interfaces"},{"label":"Robotic process automation and decision management","value":"robotic-process-automation-and-decision-management"},{"label":"Robotics and autonomous vehicles/systems","value":"robotics-and-autonomous-vehicles-systems"}],"display_as_result_metadata":true,"filterable":true,"key":"use_case","name":"Use case","preposition":"Use case","type":"text"},{"allowed_values":[{"label":"Agriculture, Forestry and Fishing (SIC Code Section A)","value":"agriculture-forestry-and-fishing"},{"label":"Mining and Quarrying (SIC Code Section B)","value":"mining-and-quarrying"},{"label":"Manufacturing (SIC Code Section C)","value":"manufacturing"},{"label":"Energy \u0026 Utilities (SIC Code Sections D \u0026 E)","value":"energy-and-utilities"},{"label":"Construction (SIC Code Section F)","value":"construction"},{"label":"Retail (SIC Code Section G)","value":"retail"},{"label":"Transportation \u0026 Storage (SIC Code Section H)","value":"transportation-and-storage"},{"label":"Accommodation and Food Service (SIC Code Section I)","value":"accommodation-and-food-service"},{"label":"Digital \u0026 Comms (SIC Code Section J)","value":"digital-and-comms"},{"label":"Financial and Insurance (SIC Code Section K)","value":"financial-and-insurance"},{"label":"Real Estate (SIC Code Section L)","value":"real-estate"},{"label":"Professional, Scientific \u0026 Professional Activities (SIC Code Section M)","value":"professional-scientific-and-professional-activities"},{"label":"Administrative \u0026 Support Services (SIC Code Section N)","value":"administrative-and-support-services"},{"label":"Public Administration \u0026 Defence (SIC Code Section O)","value":"public-administration-and-defence"},{"label":"Education (SIC Code Section P)","value":"education"},{"label":"Healthcare \u0026 Social Work (SIC Code Section Q)","value":"healthcare-and-social-work"},{"label":"Arts, Entertainment \u0026 Recreation (SIC Code Section R)","value":"arts-entertainment-and-recreation"},{"label":"Other Services (SIC Code Section S)","value":"other-services"}],"display_as_result_metadata":true,"filterable":true,"key":"sector","name":"Sector","preposition":"sector","type":"text"},{"allowed_values":[{"label":"Safety, security and robustness","value":"safety-security-and-robustness"},{"label":"Appropriate transparency and explainability","value":"appropriate-transparency-and-explainability"},{"label":"Fairness","value":"fairness"},{"label":"Accountability and governance","value":"accountability-and-governance"},{"label":"Contestability and redress","value":"contestability-and-redress"}],"display_as_result_metadata":true,"filterable":true,"key":"principle","name":"Principle","preposition":"Principle","type":"text"},{"allowed_values":[{"label":"R\u0026D","value":"r-and-d"},{"label":"Product and service development","value":"product-and-service-development"},{"label":"Manufacturing","value":"manufacturing"},{"label":"Service operations","value":"service-operations"},{"label":"Supply chain management","value":"supply-chain-management"},{"label":"Human Resources","value":"human-resources"},{"label":"Marketing and sales","value":"marketing-and-sales"},{"label":"Customer services","value":"customer-services"},{"label":"Risk management","value":"risk-management"},{"label":"Strategy and corporate finance","value":"strategy-and-corporate-finance"}],"display_as_result_metadata":true,"filterable":true,"key":"key_function","name":"Key function","preposition":"function","type":"text"},{"allowed_values":[{"label":"Data assurance","value":"data-assurance"},{"label":"Compliance audit","value":"compliance-audit"},{"label":"Formal verification","value":"formal-verification"},{"label":"Performance testing","value":"performance-testing"},{"label":"Certification","value":"certification"},{"label":"Risk Assessment","value":"risk-assessment"},{"label":"Impact Assessment","value":"impact-assessment"},{"label":"Impact Evaluation","value":"impact-evaluation"},{"label":"Conformity Assessment","value":"conformity-assessment"},{"label":"Bias Audit","value":"bias-audit"},{"label":"Assurance Warranty","value":"assurance-warranty"}],"display_as_result_metadata":true,"filterable":true,"key":"ai_assurance_technique","name":"AI Assurance Technique","preposition":"AI Assurance Technique","type":"text"},{"allowed_values":[{"label":"Technical","value":"technical"},{"label":"Procedural","value":"procedural"},{"label":"Educational","value":"educational"}],"display_as_result_metadata":true,"filterable":true,"key":"assurance_technique_approach","name":"Assurance Technique Approach","preposition":"Assurance Technique Approach","type":"text"}],"filter":{"format":"ai_assurance_portfolio_technique"},"show_metadata_block":true,"show_summaries":false,"show_table_of_contents":true,"summary":"\u003cp\u003eFind out what AI assurance is and what effective AI assurance techniques you can use in your organisation. You can also read examples of AI assurance in practice across a variety of sectors.\u003c/p\u003e\n"},"document_type":"finder","first_published_at":"2023-06-07T08:29:37+01:00","links":{"available_translations":[{"api_path":"/api/content/ai-assurance-techniques","api_url":"https://www.gov.uk/api/content/ai-assurance-techniques","base_path":"/ai-assurance-techniques","content_id":"5e5890a0-329a-42d2-9637-9d8433fe97ae","document_type":"finder","links":{},"locale":"en","public_updated_at":"2025-04-28T18:53:05Z","schema_name":"finder","title":"Find out about artificial intelligence (AI) assurance techniques","web_url":"https://www.gov.uk/ai-assurance-techniques","withdrawn":false}],"organisations":[{"analytics_identifier":"D1381","api_path":"/api/content/government/organisations/department-for-science-innovation-and-technology","api_url":"https://www.gov.uk/api/content/government/organisations/department-for-science-innovation-and-technology","base_path":"/government/organisations/department-for-science-innovation-and-technology","content_id":"c352c234-8083-47ec-8a4b-0edd45c31263","details":{"acronym":"DSIT","brand":"department-for-science-innovation-technology","default_news_image":{"high_resolution_url":"https://assets.publishing.service.gov.uk/media/68a86caf969253904d1557b7/s960_DSIT_GovUK.png","url":"https://assets.publishing.service.gov.uk/media/68a86caf960e2d135b4c8da5/s300_DSIT_GovUK.png"},"logo":{"crest":"single-identity","formatted_title":"Department for\u003cbr/\u003eScience, Innovation\u003cbr/\u003e\u0026amp; Technology"},"organisation_govuk_status":{"status":"live","updated_at":null,"url":null}},"document_type":"organisation","links":{},"locale":"en","schema_name":"organisation","title":"Department for Science, Innovation and Technology","web_url":"https://www.gov.uk/government/organisations/department-for-science-innovation-and-technology","withdrawn":false}],"related":[{"api_path":"/api/content/guidance/portfolio-of-ai-assurance-techniques","api_url":"https://www.gov.uk/api/content/guidance/portfolio-of-ai-assurance-techniques","base_path":"/guidance/portfolio-of-ai-assurance-techniques","content_id":"4519b26b-6312-4855-bc45-828123bd8a2f","document_type":"detailed_guide","links":{},"locale":"en","public_updated_at":"2023-06-06T23:00:00Z","schema_name":"detailed_guide","title":"Portfolio of AI assurance techniques","web_url":"https://www.gov.uk/guidance/portfolio-of-ai-assurance-techniques","withdrawn":false}]},"locale":"en","phase":"live","public_updated_at":"2025-04-28T19:53:05+01:00","publishing_app":"specialist-publisher","publishing_request_id":"21-1745867267.864-10.13.35.92-695","publishing_scheduled_at":null,"rendering_app":"finder-frontend","scheduled_publishing_delay_seconds":null,"schema_name":"finder","title":"Find out about artificial intelligence (AI) assurance techniques","updated_at":"2026-01-08T11:43:20+00:00","withdrawn_notice":{}}
Loading