diff --git a/.gitignore b/.gitignore index 4717b47..5c1b39b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,26 +4,51 @@ # or operating system, you probably want to add a global ignore instead: # git config --global core.excludesfile '~/.gitignore_global' -!/log/.keep -.byebug_history -.github-token -.npmrc -.tags +# Ignore vscode config .vscode -.yarn-integrity + +## Ignore bundler configuration: /.bundle +/vendor/bundle +/lib/bundler/man/ + +# Ignore all logfiles and tempfiles. /log/* -/node_modules +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore Byebug command history file. +.byebug_history + +# Ignore node_modules +node_modules/ + +# Ignore precompiled javascript packs /public/packs /public/packs-test -/tmp -coverage -fc_simple.json +/public/assets + +# Ignore uploaded files in development +/storage/* +!/storage/.keep +/public/uploads + +### Rails specific ### +.byebug_history +/public/system +/coverage/ +tmp + +# Ignore files specific to the development environment fc.json +fc_simple.json index-names.txt index.json -node_modules/ -public/assets tags -yarn-debug.log* -yarn-error.log + +# Ignore dot files used by environment or IDE tools +.tags +.tool-versions +.github-token +.npmrc diff --git a/CHANGELOG.md b/CHANGELOG.md index dcd2383..afafc46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,33 @@ This app presents the landing page experience for landregistry.data.gov.uk, including the SPARQL Qonsole +## 1.8.0 - 2024-09 + +- (Jon) Moved all mirrored configuration settings from individual environments + into the application configuration to reduce the need to manage multiple + sources of truth +- (Bogdan) Fixed a bug where the language selector was not working correctly + when the user was on the accessibility or privacy pages + [GH-130](https://github.com/epimorphics/lr-landing/issues/130) +- (Jon) Implemented improved boilerplate metrics integration to offer analysis + of current application usage stats +- (Jon) Implemented the dynamic page title approach used in the other suite apps + to the accessibility and privacy translation templates +- (Jon) Converted the privacy templates to match the same haml formatting + language used in the app +- (Jon) Tweaked the application controller to improve selected language option + to be applied for the pages +- (Jon) Reorganised makefile targets alphabetically as well as mirrored other + improvements from the other applications in the suite +- (Jon) Updated .gitignore file to mirror the current approach in the other HMLR + apps + +## 1.7.7 - 2024-08 + +- (Dan) Updates gemfile to use v1.9.5 lr_common_styles +- (Dan) Adds underlines to links in body text to meet WCAG 2.2 accessibility + requirements [GH-126](https://github.com/epimorphics/lr-landing/issues/126) + ## 1.7.6 - 2024-06 - (Jon) - Updated the deployment.yaml file to mirror the new branch names post @@ -26,7 +53,8 @@ including the SPARQL Qonsole - (Jon) Updated the `app/controllers/application_controller.rb` to include the `before_action` for the `change_default_caching_policy` method to ensure the - default `Cache-Control` header for all requests is set to 5 minutes (300 seconds). + default `Cache-Control` header for all requests is set to 5 minutes (300 + seconds). ## 1.7.3 - 2023-06-07 @@ -55,8 +83,8 @@ including the SPARQL Qonsole - (Jon) Updated and improved the build files for the new infrastructure use. - (Jon) Minor text changes to the `Gemfile` to include instructions for running Epimorphics specific gems locally during the development of those gems. -- (Jon) Updated the production `json_rails_logger` gem version to be at least the - current version `~>0.3.5` (this is to cover out of sync release versions) +- (Jon) Updated the production `json_rails_logger` gem version to be at least + the current version `~>0.3.5` (this is to cover out of sync release versions) - (Jon) Updated the production `lr_common_styles` gem version to be at least the current version `~>1.9.1` (this is to cover out of sync release versions) - (Jon) Refactored the version cadence creation to include a SUFFIX value if diff --git a/Gemfile b/Gemfile index f34a12f..e61a083 100644 --- a/Gemfile +++ b/Gemfile @@ -14,6 +14,7 @@ gem 'jquery-rails' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' +gem 'get_process_mem', '~> 0.2.7' gem 'haml-rails', '~> 2.0.0' gem 'http_accept_language' gem 'prometheus-client', '~> 4.0' @@ -37,7 +38,7 @@ end # ! These "local" paths do not work with a docker image - use the repo instead # gem 'qonsole-rails', path: '~/Epimorphics/clients/land-registry/projects/qonsole-rails' # gem 'json_rails_logger', '~> 1.0.0', path: '~/Epimorphics/shared/json-rails-logger/' -# gem 'lr_common_styles', '~> 1.9.3', path: '~/Epimorphics/clients/land-registry/projects/lr_common_styles/' +# gem 'lr_common_styles', '~> 1.9.0', path: '~/Epimorphics/clients/land-registry/projects/lr_common_styles/' # rubocop:enable Layout/LineLength # TODO: In production you want to set this to the gem from the epimorphics github repo @@ -46,5 +47,5 @@ gem 'qonsole-rails', git: 'https://github.com/epimorphics/qonsole-rails' # TODO: In production you want to set this to the gem from the epimorphics package repo source 'https://rubygems.pkg.github.com/epimorphics' do gem 'json_rails_logger', '~> 1.0.0' - gem 'lr_common_styles', '~> 1.9.3' + gem 'lr_common_styles', '~> 1.9.0' end diff --git a/Gemfile.lock b/Gemfile.lock index 20b1477..43f5b37 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -61,7 +61,7 @@ GEM tzinfo (~> 1.1) arel (9.0.0) ast (2.4.2) - autoprefixer-rails (10.4.16.0) + autoprefixer-rails (10.4.19.0) execjs (~> 2) bindex (0.8.1) bootstrap-sass (3.4.1) @@ -85,6 +85,8 @@ GEM ffi (1.15.5) font-awesome-rails (4.7.0.8) railties (>= 3.2, < 8.0) + get_process_mem (0.2.7) + ffi (~> 1.0) globalid (1.0.1) activesupport (>= 5.0) govuk_elements_rails (2.0.0) @@ -155,7 +157,7 @@ GEM parser (3.1.1.0) ast (~> 2.4.1) prometheus-client (4.0.0) - puma (5.6.7) + puma (6.4.2) nio4r (~> 2.0) racc (1.6.2) rack (2.2.8) @@ -263,14 +265,14 @@ GEM json lograge railties - lr_common_styles (1.9.3) + lr_common_styles (1.9.8) bootstrap-sass (~> 3.4.0) font-awesome-rails (~> 4.7.0.1) govuk_elements_rails (~> 2.0.0) govuk_frontend_toolkit (~> 4.18.1) govuk_template (~> 0.18.1) haml-rails (~> 2.0.0) - jquery-rails (~> 4.3.5) + jquery-rails (>= 4.3.5, < 4.7.0) lodash-rails (~> 4.17.14) modernizr-rails (~> 2.7.1) modulejs-rails (~> 2.2.0.0) @@ -285,12 +287,13 @@ PLATFORMS DEPENDENCIES byebug + get_process_mem (~> 0.2.7) haml-rails (~> 2.0.0) http_accept_language jbuilder (~> 2.0) jquery-rails json_rails_logger (~> 1.0.0)! - lr_common_styles (~> 1.9.3)! + lr_common_styles (~> 1.9.0)! prometheus-client (~> 4.0) puma qonsole-rails! diff --git a/Makefile b/Makefile index eb3bfe3..a8aa0c4 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: assets clean image lint publish realclean run tag test vars +.PHONY: assets auth check clean image lint local publish realclean run tag test vars ACCOUNT?=$(shell aws sts get-caller-identity | jq -r .Account) ALPINE_VERSION?=3.13 @@ -27,23 +27,27 @@ REPO?=${ECR}/${IMAGE} GITHUB_TOKEN=.github-token BUNDLE_CFG=.bundle/config -all: image - ${BUNDLE_CFG}: ${GITHUB_TOKEN} @./bin/bundle config set --local rubygems.pkg.github.com ${GPR_OWNER}:`cat ${GITHUB_TOKEN}` ${GITHUB_TOKEN}: @echo ${PAT} > ${GITHUB_TOKEN} -assets: - @./bin/bundle config set --local without 'development' +all: image + +assets: auth + @./bin/bundle config set --local without 'development test' @./bin/bundle install @./bin/rails assets:clean assets:precompile auth: ${GITHUB_TOKEN} ${BUNDLE_CFG} +check: lint test + @echo "All checks passed." + clean: @[ -d public/assets ] && ./bin/rails assets:clobber || : + @@ rm -rf bundle coverage log node_modules image: auth @echo Building ${REPO}:${TAG} ... @@ -63,6 +67,12 @@ image: auth lint: assets @./bin/bundle exec rubocop +local: + @echo "Installing all packages ..." + @./bin/bundle install + @echo "Starting local server ..." + @./bin/rails server -p ${PORT} + publish: image @echo Publishing image: ${REPO}:${TAG} ... @docker push ${REPO}:${TAG} 2>&1 @@ -71,16 +81,23 @@ publish: image realclean: clean @rm -f ${GITHUB_TOKEN} ${BUNDLE_CFG} -run: +run: start @if docker network inspect dnet > /dev/null 2>&1; then echo "Using docker network dnet"; else echo "Create docker network dnet"; docker network create dnet; sleep 2; fi + @docker run -p ${PORT}:3000 -e API_SERVICE_URL=${API_SERVICE_URL} --network dnet --rm --name ${SHORTNAME} ${REPO}:${TAG} + +server: assets start + @export SECRET_KEY_BASE=$(./bin/rails secret) + @API_SERVICE_URL=${API_SERVICE_URL} ./bin/rails server -p ${PORT} + +start: @docker stop ${SHORTNAME} > /dev/null 2>&1 || : @echo "Starting ${SHORTNAME} ..." - @docker run -p ${PORT}:3000 --network dnet --rm --name ${SHORTNAME} ${REPO}:${TAG} tag: @echo ${TAG} test: assets + @echo "Running unit tests ..." @./bin/rails test vars: diff --git a/README.md b/README.md index fee63ae..4846a39 100644 --- a/README.md +++ b/README.md @@ -9,172 +9,4 @@ Please see the other repositories in the [HM Land Registry Open Data](https://github.com/epimorphics/hmlr-linked-data/) project for more details. -## Running the app locally - -### In development mode - -Begin by cloning [the Github repo](https://github.com/epimorphics/lr-landing) -and installing the dependencies: - -```sh -git clone git@github.com:epimorphics/lr-landing.git && -cd lr-landing && -bundle install -``` - -Start the app locally for development: - -```sh -rails server -``` - -If you want to be able to test `Qonsole` locally, you will need to run the app -with the `API_SERVICE_URL` environment variable set to the URL of the Data API: - -```sh -API_SERVICE_URL=http://localhost:8888 rails server -``` - -Visit to view the local instance. - -### In production mode - -Unlike other HMLR applications, the Landing application does not run run from a -sub-directory. - -As such **Production** *and* **Development** modes run at the same path. - -If running more than one application locally you need to ensure that each is -listening on a separate port. In the case of running local docker images, the -required configuration is captured in the application's `Makefile` and an image -can be run by using: - -```sh -make image run -``` - -or, if the image is already built, simply - -```sh -make run -``` - -You can start a production mode rails server locally using the following -command: - -```sh -rails server -e production -``` - -N.B Ommitting the `-e` flag will default to `development` mode. - -To test the running application visit in your browser. - -For more information on how to running a proxy to mimic production and run -multple services together see -[simple-web-proxy](https://github.com/epimorphics/simple-web-proxy/) - -With the proxy and Docker container running you can access the application as -[`localhost:8080`](http://localhost:8080) (note the lack of trailing path). - -## Additional Information - -### Updating the code - -This is a pretty standard, and quite small, Rails app. - -Please keep the [changelog](CHANGELOG.md) up-to-date, and increment the -[`/app/lib/version.rb`](https://github.com/epimorphics/lr-landing/app/lib/version.rb) -identifier in line with semver principles. - -### Coding standards - -#### Running code linting - -```sh -rubocop -``` - -Rubocop should always return no errors or warnings. - -```sh -Inspecting 30 files -.............................. - -30 files inspected, no offenses detected -``` - -#### Running integration tests - -```sh -rails test -``` - -Tests should always return as passing: - -```sh -Run options: --seed ##### - -# Running: -[...] - -Finished in 1.050748s, 6.6619 runs/s, 8.5653 assertions/s. -7 runs, 9 assertions, 0 failures, 0 errors, 0 skips -``` - -### Deployment - -The detailed deployment mapping is described in `deployment.yml`. At the time of -writing, using the new infrastructure, the deployment process is as follows: - -- commits to the `dev-infrastructure` branch will deploy the `dev` server -- commits to the `preprod` branch will deploy the `pre-production` server -- any commit on the `prod` branch will deploy the `production` server as a new - release - -If the commit is a "new" release, the deployment should be tagged with the same -version number, e.g. `1.2.3`. as set in the `/app/lib/version.rb` and a short -annotation summarising the updates should be included in the tag. - -Once the production deployment has been completed and verified, please create a -release on the repository using the same latest version number. Utilise the -`Generate release notes from commit log` option to create specific notes on the -contained changes as well as the ability to diff agains the previous version. - -#### `entrypoint.sh` - -- There is a workaround to removing the PID lock of the Rails process in the - event of the application crashing and not releasing the process. -- The rails `SECRET_KEY_BASE` is created here. - -### Runtime Configuration environment variables - -We can use a number of environment variables to determine the runtime behaviour -of the application while developing the codebase locally: - -| name | description | -| -------------------------- | -------------------------------------------------------------------- | -| `SENTRY_API_KEY` | The Sentry DSN client key for the `lr-dgu-landing` Sentry app | - -### Dependent gems - -Most of the local (i.e. Epimorphics) gems that this project depends on are -served via GitHub Package Registry (GPR). Specifically, `lr_common_styles` and -`json-rails-logger`. - -However, `qonsole-rails` is **not** served via GPR at present, mostly because we -are hoping to retire it in favour of a new implementation of Qonsole. Since -`qonsole-rails` is a public repo, this dependency does not require us to lean on -the old pattern of using an ssh key to serve private gems directly from a GitHub -repo. - -Accessing gems from GPR will require a personal access token (PAT). To store -this locally, use `make auth` to set your GitHub Token using the PAT. - -To create a PAT, see [the Epimorphics -wiki](https://github.com/epimorphics/internal/wiki/Ansible-CICD#creating-a-pat-for-gpr-access). - -### Issues - -Please add issues to the [shared issues -list](https://github.com/epimorphics/hmlr-linked-data/issues) +For more information about this project visit [the wiki](https://github.com/epimorphics/lr-landing/wiki). diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 579491b..88fe7b5 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -5,3 +5,12 @@ "bootstrap", "qonsole_rails/application", "lr_common_styles/lr-common"; + +.row { + li,p,dl>dt,dl>dd { + a { + text-decoration: underline; + } + } +} + \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9df9271..aba30ba 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,19 +4,17 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. - protect_from_forgery with: :exception - - before_action :set_locale, :change_default_caching_policy - private + protect_from_forgery with: :exception + before_action :set_locale + before_action :change_default_caching_policy - # Set the user's preferred locale. An explicit locale set via - # the URL param `lang` is preeminent, otherwise we look to the - # user's preferred language specified via browser headers + # Set the user's preferred locale. An explicit locale set via the URL param + # `lang` is preeminent, otherwise we look to the user's preferred language + # specified via browser headers def set_locale - user_locale = - params['lang'] || - http_accept_language.compatible_language_from(I18n.available_locales) + user_locale = params['lang'] + user_locale ||= http_accept_language.compatible_language_from(I18n.available_locales) I18n.locale = user_locale if Rails.application.config.welsh_language_enabled end @@ -28,4 +26,13 @@ def set_locale def change_default_caching_policy expires_in 5.minutes, public: true, must_revalidate: true if Rails.env.production? end + + # Notify subscriber(s) of an internal error event with the payload of the + # exception once done + # @param [Exception] exp the exception that caused the error + # @return [ActiveSupport::Notifications::Event] provides an object-oriented + # interface to the event + def instrument_internal_error(exception) + ActiveSupport::Notifications.instrument('internal_error.application', exception: exception) + end end diff --git a/app/lib/version.rb b/app/lib/version.rb index 4b828a8..38bc7ca 100644 --- a/app/lib/version.rb +++ b/app/lib/version.rb @@ -2,8 +2,8 @@ module Version MAJOR = 1 - MINOR = 7 - REVISION = 6 + MINOR = 8 + REVISION = 0 SUFFIX = nil VERSION = "#{MAJOR}.#{MINOR}.#{REVISION}#{SUFFIX && ".#{SUFFIX}"}" end diff --git a/app/subscribers/action_dispatch_prometheus_subscriber.rb b/app/subscribers/action_dispatch_prometheus_subscriber.rb new file mode 100644 index 0000000..217f87e --- /dev/null +++ b/app/subscribers/action_dispatch_prometheus_subscriber.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +# Subscribe to `*.action_controller`` events +# +# Note: This is Rails 5 specific. In Rails 6, we'd subscribe to +# `request.action_dispatch` +class ActionDispatchPrometheusSubscriber < ActiveSupport::Subscriber + attach_to :action_controller + + # rubocop:disable Metrics/AbcSize + def process_action(_event) + mem = GetProcessMem.new + Prometheus::Client.registry + .get(:memory_used_mb) + .set(mem.mb) + # description: 'Thread is aborting' + Prometheus::Client.registry + .get(:process_threads) + .set( + Thread.list.select { |thread| thread.status == 'aborting' }.count, + labels: { + status: 'aborting' + } + ) + # description: 'Thread is sleeping or waiting on I/O' + Prometheus::Client.registry + .get(:process_threads) + .set( + Thread.list.select { |thread| thread.status == 'sleep' }.count, + labels: { + status: 'sleep' + } + ) + # description: 'Thread is executing' + Prometheus::Client.registry + .get(:process_threads) + .set( + Thread.list.select { |thread| thread.status == 'run' }.count, + labels: { + status: 'run' + } + ) + # description: 'Thread is terminated normally' + Prometheus::Client.registry + .get(:process_threads) + .set( + Thread.list.select { |thread| thread.status == false }.count, + labels: { + status: 'false' + } + ) + # description: 'Thread is terminated with an exception' + Prometheus::Client.registry + .get(:process_threads) + .set( + Thread.list.select { |thread| thread.status.nil? }.count, + labels: { + status: 'nil' + } + ) + end + # rubocop:enable Metrics/AbcSize +end diff --git a/app/subscribers/api_prometheus_subscriber.rb b/app/subscribers/api_prometheus_subscriber.rb new file mode 100644 index 0000000..ab4ab17 --- /dev/null +++ b/app/subscribers/api_prometheus_subscriber.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +# Subscribe to :data_api events +class ApiPrometheusSubscriber < ActiveSupport::Subscriber + attach_to :api + + # rubocop:disable Metrics/MethodLength + def response(event) + response = event.payload[:response] + duration = event.payload[:duration] + status = response.status.to_s + + Prometheus::Client.registry + .get(:api_status) + .increment(labels: { status: status }) + + Prometheus::Client.registry + .get(:api_requests) + .increment(labels: { result: 'success' }) + + Prometheus::Client.registry + .get(:api_response_times) + .observe(duration) + end + # rubocop:enable Metrics/MethodLength + + def connection_failure(event) + exception = event.payload[:exception] + message = exception.message || exception.to_s + + Prometheus::Client.registry + .get(:api_requests) + .increment(labels: { result: 'failure' }) + + Prometheus::Client.registry + .get(:api_connection_failure) + .increment(labels: { message: message }) + end + + def service_exception(event) + exception = event.payload[:exception] + status = exception_status(exception) + + return if status == 404 + + Prometheus::Client.registry + .get(:api_service_exception) + .increment(labels: { status: status }) + end + + private + + def exception_status(exception) + status = 500 + + begin + json = JSON.parse(exception.message) + status = json['status'] if json&.key?('status') + rescue JSON::ParserError + # was not JSON after all + end + + status = exception.status if exception.respond_to?(:status) + + status + end +end diff --git a/app/subscribers/application_prometheus_subscriber.rb b/app/subscribers/application_prometheus_subscriber.rb new file mode 100644 index 0000000..245a6fd --- /dev/null +++ b/app/subscribers/application_prometheus_subscriber.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# Subscribe to :application events +class ApplicationPrometheusSubscriber < ActiveSupport::Subscriber + attach_to :application + + def internal_error(event) + message = event.payload[:exception] + Prometheus::Client.registry + .get(:internal_application_error) + .increment(labels: { message: message.to_s }) + end +end diff --git a/app/views/doc/_accessibility_cy.html.haml b/app/views/doc/_accessibility_cy.html.haml index 41bbe2b..cf855ee 100644 --- a/app/views/doc/_accessibility_cy.html.haml +++ b/app/views/doc/_accessibility_cy.html.haml @@ -1,7 +1,8 @@ +- content_for(:title, 'Datganiad hygyrchedd') +- content_for(:description, 'Datganiad hygyrchedd ar gyfer cymwysiadau data agored: archwiliwr Data Pris a Dalwyd, adeiladwr adroddiadau safonol a Mynegai Prisiau Tai y DU') %article %h1.heading-large - Datganiad hygyrchedd ar gyfer cymwysiadau data agored: archwiliwr Data Pris a - Dalwyd, adeiladwr adroddiadau safonol a Mynegai Prisiau Tai y DU + = yield(:description) %p Cofrestrfa Tir EM sy’n rhedeg y wefan hon. Rydym am i gynifer o bobl â diff --git a/app/views/doc/_accessibility_en.html.haml b/app/views/doc/_accessibility_en.html.haml index 707be84..df9d8ba 100644 --- a/app/views/doc/_accessibility_en.html.haml +++ b/app/views/doc/_accessibility_en.html.haml @@ -1,8 +1,8 @@ +- content_for(:title, 'Accessibility statement') +- content_for(:description, 'Accessibility statement for open data applications: Price Paid Data (PPD) explorer, standard reports builder and UK House Price Index (UKHPI)') %article %h1.heading-large - Accessibility statement for open data applications: Price Paid - Data (PPD) explorer, standard reports builder and UK House - Price Index (UKHPI) + = yield(:description) %p This website is run by HM Land Registry. We want as many people as diff --git a/app/views/doc/_privacy_cy.html.erb b/app/views/doc/_privacy_cy.html.haml similarity index 64% rename from app/views/doc/_privacy_cy.html.erb rename to app/views/doc/_privacy_cy.html.haml index d74c0ff..5f8b6e7 100644 --- a/app/views/doc/_privacy_cy.html.erb +++ b/app/views/doc/_privacy_cy.html.haml @@ -1,37 +1,53 @@ -
-

Hysbysiad preifatrwydd

-

+- content_for(:title, 'Hysbysiad preifatrwydd') + +%article + %h1 + = yield(:title) + + %p Mae’r hysbysiad preifatrwydd hwn yn egluro beth rydym yn ei wneud gyda’r wybodaeth a gawn oddi wrthych pan fyddwch yn defnyddio’n gwasanaeth. -

-

Cwcis

-

+ + %h2 + Cwcis + %p Ffeiliau bach sy’n cael eu harbed ar eich ffôn, llechen neu gyfrifiadur pan fyddwch yn ymweld â gwefan yw cwcis. Rydym yn defnyddio cwcis i wneud i’r wefan weithio ac i ddeall sut rydych yn defnyddio’n gwasanaeth, er enghraifft y tudalennau rydych yn ymweld â nhw. -

-

Cwcis hanfodol

-

+ + %h3 + Cwcis hanfodol + %p Mae cwcis hanfodol yn cadw’ch gwybodaeth yn ddiogel wrth ichi ddefnyddio’r gwasanaeth hwn. Nid oes angen eich caniatâd arnom i’w defnyddio. -

-
    -
  • Dynodydd sesiwn unigryw
  • -
-

Cwcis dadansoddol (dewisol)

-

+ + %ul.list.list-bullet + %li + Dynodydd sesiwn unigryw + + + %h3 + Cwcis dadansoddol (dewisol) + %p Gyda’ch caniatâd, rydym yn defnyddio Google Analytics i gasglu data am sut rydych yn defnyddio’r gwasanaeth. Rydym yn defnyddio’r wybodaeth hon i’n helpu i wella’r gwasanaeth ar sail anghenion defnyddwyr. -

-

+ + %p Ni chaniateir i Google ddefnyddio neu rannu ein data dadansoddol gydag unrhyw un. -

-

+ + %p Mae Google Analytics yn gosod cwcis sy’n storio gwybodaeth ddienw am y canlynol: -

-
    -
  • y tudalennau rydych yn ymweld â nhw
  • -
  • pa mor hir rydych yn ei dreulio ar bob tudalen
  • -
  • sut y cyrhaeddwyd y gwasanaeth
  • -
  • ar beth rydych yn clicio wrth ymweld â’r gwasanaeth
  • -
-

Cwcis sy’n cofio’ch gosodiadau

-

+ + %ul.list.list-bullet + %li + y tudalennau rydych yn ymweld â nhw + + %li + pa mor hir rydych yn ei dreulio ar bob tudalen + + %li + sut y cyrhaeddwyd y gwasanaeth + + %li + ar beth rydych yn clicio wrth ymweld â’r gwasanaeth + + + %h3 + Cwcis sy’n cofio’ch gosodiadau + %p Mae’r cwcis hyn yn gwneud pethau fel cofio eich ffafriaeth a’r dewisiadau a wnewch i bersonoli’ch profiad o ddefnyddio’r wefan. -

-
diff --git a/app/views/doc/_privacy_en.html.erb b/app/views/doc/_privacy_en.html.haml similarity index 52% rename from app/views/doc/_privacy_en.html.erb rename to app/views/doc/_privacy_en.html.haml index bc83b70..231b52f 100644 --- a/app/views/doc/_privacy_en.html.erb +++ b/app/views/doc/_privacy_en.html.haml @@ -1,40 +1,50 @@ -
-

Privacy notice

-

+- content_for(:title, 'Privacy notice') + +%article + %h1 + = yield(:title) + %p This privacy notice tells you what we do with the information we collect from you when you use our service. -

-

Cookies

-

+ %h2 + Cookies + %p Cookies are small files saved on your phone, tablet or computer when you visit a website. We use cookies to make the site work and understand how you use our service, such as the pages you visit. -

-

Essential cookies

-

+ %h3 + Essential cookies + %p Essential cookies keep your information secure while you use this service. We do not need your permission to use them. -

-
    -
  • Unique session ID
  • -
-

Analytics cookies (optional)

-

+ %ul.list.list-bullet + %li + Unique session ID + + %h3 + Analytics cookies (optional) + %p With your permission, we use Google Analytics to collect data about how you use the service. We use this information to help us improve the service based on user needs. -

-

Google is not allowed to use or share our analytics data with anyone.

-

Google analytics sets cookies that store anonymised information about:

-
    -
  • the pages you visit
  • -
  • how long you spend on each page
  • -
  • how you got to the service
  • -
  • what you click on while you're visiting the service
  • -
-

Cookies that remember your settings

-

+ + %p + Google is not allowed to use or share our analytics data with anyone. + %p + Google analytics sets cookies that store anonymised information about: + %ul.list.list-bullet + %li + the pages you visit + %li + how long you spend on each page + %li + how you got to the service + %li + what you click on while you're visiting the service + + %h3 + Cookies that remember your settings + %p These cookies do things like remember your preferences and the choices you make to personalise your experience of using the site. -

-
+ diff --git a/app/views/doc/hpi.html.haml b/app/views/doc/hpi.html.haml index f49beac..e2aa049 100644 --- a/app/views/doc/hpi.html.haml +++ b/app/views/doc/hpi.html.haml @@ -1,4 +1,7 @@ -%h2 House Price Index Linked Data +- content_for(:title, 'House Price Index Linked Data') + +%h2 + = yield(:title) %h3 What does the House Price Index Dataset consist of? %p diff --git a/app/views/doc/ppd.html.haml b/app/views/doc/ppd.html.haml index e3a3125..9e6485a 100644 --- a/app/views/doc/ppd.html.haml +++ b/app/views/doc/ppd.html.haml @@ -1,4 +1,6 @@ -%h1 Price Paid Linked Data +- content_for(:title, 'Price Paid Linked Data') +%h1 + = yield(:title) %h2 What does the Price Paid Dataset consist of? %p HM Land Registry publish Price Paid Data for England and Wales on a monthly basis. New transactions are added diff --git a/app/views/doc/privacy.html.erb b/app/views/doc/privacy.html.erb deleted file mode 100644 index 4507eed..0000000 --- a/app/views/doc/privacy.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<%= render partial: 'shared/lang_switch' %> -<%= render partial: "privacy_#{I18n.locale}"%> diff --git a/app/views/doc/privacy.html.haml b/app/views/doc/privacy.html.haml new file mode 100644 index 0000000..38fa68c --- /dev/null +++ b/app/views/doc/privacy.html.haml @@ -0,0 +1,2 @@ += render partial: 'shared/lang_switch' += render partial: "privacy_#{I18n.locale}" diff --git a/app/views/landing/_index_cy.html.haml b/app/views/landing/_index_cy.html.haml index bcdadcb..e4fe374 100644 --- a/app/views/landing/_index_cy.html.haml +++ b/app/views/landing/_index_cy.html.haml @@ -1,7 +1,9 @@ +- content_for(:title, 'Data Agored') .row .col-md-12 %h1.heading-large - Data Agored + = yield(:title) + %p Mae Cofrestrfa Tir EM yn cyhoeddi’r setiau data cyhoeddus canlynol fel rhan o’n hymrwymiad i flaenoriaethau’r Llywodraeth i dwf economaidd diff --git a/app/views/landing/_index_en.html.haml b/app/views/landing/_index_en.html.haml index bd47045..1d3426c 100644 --- a/app/views/landing/_index_en.html.haml +++ b/app/views/landing/_index_en.html.haml @@ -1,7 +1,8 @@ +- content_for(:title, 'Open Data') .row .col-md-12 %h1.heading-large - Open Data + = yield(:title) %p HM Land Registry publishes the following public datasets on GOV.UK as part of our commitment to the Government’s priorities diff --git a/app/views/landing/hpi.html.haml b/app/views/landing/hpi.html.haml index 738d774..2928bb7 100644 --- a/app/views/landing/hpi.html.haml +++ b/app/views/landing/hpi.html.haml @@ -1,4 +1,6 @@ -%h1 Change to House Price Index data +- content_for(:title, "Change to House Price Index data" ) +%h1 + = yield(:title) %p From 14 June 2016 the HM Land Registry House Price Index was replaced by the %strong UK House Price Index, diff --git a/config.ru b/config.ru index 4cb621b..7b7256b 100644 --- a/config.ru +++ b/config.ru @@ -1,14 +1,15 @@ # frozen_string_literal: true # This file is used by Rack-based servers to start the application. - require_relative 'config/environment' -require 'prometheus/middleware/collector' -require 'prometheus/middleware/exporter' +unless Rails.env.test? + require 'prometheus/middleware/collector' + require 'prometheus/middleware/exporter' -use Prometheus::Middleware::Collector -use Prometheus::Middleware::Exporter + use Prometheus::Middleware::Collector + use Prometheus::Middleware::Exporter +end require ::File.expand_path('config/environment', __dir__) diff --git a/config/application.rb b/config/application.rb index 87174fe..47e404f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -34,8 +34,9 @@ def print_boot_information level: 'INFO', message: "Starting #{server} Rails #{Rails.version} in #{Rails.env} #{origin}" } - - puts(msg.to_json) # rubocop:disable Rails/Output + # rubocop:disable Rails/Output + puts(msg.to_json) + # rubocop:enable Rails/Output end end end @@ -47,12 +48,24 @@ class Application < Rails::Application # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. + # Use default paths for documentation. + config.accessibility_document_path = '/accessibility' + config.privacy_document_path = '/privacy' + + # feature flag for showing the Welsh language switch affordance + config.welsh_language_enabled = true + + # Set the contact email address to Land Registry supplied address + config.contact_email_address = 'data.services@mail.landregistry.gov.uk' + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de + config.i18n.enforce_available_locales = true + config.i18n.default_locale = :en + config.i18n.available_locales = %i[en cy] end end diff --git a/config/environments/development.rb b/config/environments/development.rb index 1141c3b..8b69f5b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -55,14 +55,4 @@ # API location can be specified in the environment but defaults to the dev service # Here we are still providing the API_SERVICE_URL for qonsole config.api_service_url = ENV.fetch('API_SERVICE_URL', 'http://localhost:8888') - - # Use default paths for documentation. - config.accessibility_document_path = '/doc/accessibility' - config.privacy_document_path = '/doc/privacy' - - # feature flag for showing the Welsh language switch affordance - config.welsh_language_enabled = true - - # Set the contact email address to Land Registry supplied address - config.contact_email_address = 'data.services@mail.landregistry.gov.uk' end diff --git a/config/environments/production.rb b/config/environments/production.rb index b83fc2c..9ead92d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -89,14 +89,4 @@ # API location can be specified in the environment # But defaults to the dev service # API location is not used on the landing page, but is required by all other apps - - # Use default paths for documentation. - config.accessibility_document_path = '/accessibility' - config.privacy_document_path = '/privacy' - - # feature flag for showing the Welsh language switch affordance - config.welsh_language_enabled = true - - # Set the contact email address to Land Registry supplied address - config.contact_email_address = 'data.services@mail.landregistry.gov.uk' end diff --git a/config/environments/test.rb b/config/environments/test.rb index 5025e19..ac3449e 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -43,14 +43,4 @@ $stdout.sync = true # Log the stdout output to the Epimorphics JSON logging gem config.logger = JsonRailsLogger::Logger.new($stdout) - - # Use default paths for documentation. - config.accessibility_document_path = '/doc/accessibility' - config.privacy_document_path = '/doc/privacy' - - # feature flag for showing the Welsh language switch affordance - config.welsh_language_enabled = true - - # Set the contact email address to Land Registry supplied address - config.contact_email_address = 'data.services@mail.landregistry.gov.uk' end diff --git a/config/initializers/prometheus.rb b/config/initializers/prometheus.rb new file mode 100644 index 0000000..df1d07b --- /dev/null +++ b/config/initializers/prometheus.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +prometheus = Prometheus::Client.registry + +# Prometheus counters +prometheus.counter( + :api_status, + docstring: 'Count of API responses, labelled by status', + labels: [:status] +) + +prometheus.counter( + :api_requests, + docstring: 'Count of API responses, labelled by succeeded true/false', + labels: [:result] +) + +prometheus.counter( + :api_connection_failure, + docstring: 'Total of failures to connect to API, labelled by reason', + labels: [:message] +) + +prometheus.counter( + :api_service_exception, + docstring: 'Total of other errors when processing API responses', + labels: [:status] +) + +prometheus.counter( + :internal_application_error, + docstring: 'Unexpected events and internal error count', + labels: [:message] +) + +# Prometheus gauges +prometheus.gauge( + :memory_used_mb, + docstring: 'Process memory usage in mb' +) + +prometheus.gauge( + :process_threads, + docstring: 'The number of process threads, labelled by status', + labels: [:status], + preset_labels: { status: 'total' } +) + +# Histograms + +prometheus.histogram( + :api_response_times, + docstring: 'Histogram of back-end API response times', + buckets: Prometheus::Client::Histogram.exponential_buckets(start: 0.0005, count: 16) +) diff --git a/config/routes.rb b/config/routes.rb index fa10994..bde123a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,6 +12,6 @@ get 'doc/ppd', to: 'doc#ppd', as: 'ppd_doc' get 'doc/ukhpi-dsd', to: redirect('/app/ukhpi/doc/ukhpi-dsd', status: 302) get 'doc/ukhpi-user-guide', to: redirect('/app/ukhpi/doc/ukhpi-user-guide', status: 302) - get 'doc/accessibility', to: 'doc#accessibility' - get 'doc/privacy', to: 'doc#privacy' + get 'accessibility', to: 'doc#accessibility' + get 'privacy', to: 'doc#privacy' end