Skip to content

Commit

Permalink
Merge branch 'dev' into task/release-candidate-v1.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrandahl committed Apr 30, 2024
2 parents 1192ab2 + c115d54 commit eb508b9
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 84 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
uses: "epimorphics/github-workflows/.github/workflows/deploy.yml@reusable"
with:
# Repostory specific
ansible_playbook: pres.yml
ansible_repo: epimorphics/hmlr-ansible-deployment
ansible_repo_ref: master
host_prefix: hmlr
Expand Down
56 changes: 40 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,57 @@
# Ignore vscode config
.vscode

# Ignore bundler config.
!/log/.keep
.byebug_history
.yarn-integrity
.tags
!/log/.keep
## 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
bower_components/
coverage
/public/assets

# Ignore yarn files
/yarn-error.log
yarn-debug.log*
.yarn-integrity

# Ignore uploaded files in development
/storage/*
!/storage/.keep
/public/uploads

### Rails specific ###
/public/system
/coverage/
/spec/tmp

# Ignore files specific to the development environment
fc.json
fc_simple.json
index-names.txt
index.json
node_modules/
public/assets/
query-results.json
tags
uk.geojson
uk.json
yarn-debug.log*
yarn-error.log

# Used by the location.rake task, don't delete or commit
query-results.json

# Ignore dot files used by environment or IDE tools
.tags
.tool-versions
.github-token
.npmrc
.npmrc
2 changes: 0 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ Rails/ActiveRecordCallbacksOrder:
Enabled: true
Rails/FindById:
Enabled: true
Rails/I18nLocaleAssignment:
Enabled: false
Rails/Inquiry:
Enabled: true
Rails/MailerName:
Expand Down
21 changes: 18 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@

## unreleased

## 1.7.4 - 2024-04-19

- (Jon) Updated print presenter to use
[`.try(:first)`](https://apidock.com/rails/Object/try) which resolves by
returning `nil` without failing if the requested element does not have the
method `.first`, i.e. is empty or nil
[GH-396](https://github.com/epimorphics/ukhpi/issues/396)
- (Jon) Updated the print template to include the Google Analytics tracking
script for the print page as well as importing shared header content for
unification of presentation
- (Jon) Minor tweaks to the Makefile to remove duplicate variables (`SHORTNAME`)
as well as introducing new targets for `check` and `local` for streamlined
development tasks

## 1.7.3 - 2024-03-15

- (Jon) Updated puma.rb configuration to accept both `RAILS_MIN_THREADS` and
`RAILS_MAX_THREADS` environment variables to allow a more flexible configuration
for the application to run in different environments.
`RAILS_MAX_THREADS` environment variables to allow a more flexible
configuration for the application to run in different environments.
[GH-143](https://github.com/epimorphics/hmlr-linked-data/issues/143)
- (Jon) Updated the UKHPI contact form links to point to the new contact form
page; both the English and Welsh versions
Expand All @@ -32,7 +46,8 @@
object and interpolating the variables, and which takes time. Therefore, it's
recommended to pass blocks to the logger methods, as these are only evaluated
if the output level is the same or included in the allowed level (i.e. lazy
loading). [Documentation](http://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance)
loading).
[Documentation](http://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance)
- (Jon) Removed sentry logging from dev instance
- (Jon) Improved logging status with allowance for the differences between 400
and 500 errors handled by the same method.
Expand Down
23 changes: 13 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,12 @@ gem 'yajl-ruby', require: 'yajl'

group :development, :test do
gem 'byebug'
gem 'capybara_minitest_spec'
gem 'haml-lint'
gem 'json_expressions'
gem 'm'
gem 'minitest-rails', '~> 6.0'
gem 'minitest-reporters'
# gem 'minitest-spec-rails'
gem 'mocha'
gem 'nokogiri', '1.13.10' # This is the highest version that supports Ruby 2.6
gem 'oj'
gem 'oj', '3.14.2' # This is the highest version that supports Ruby 2.6
gem 'rubocop', require: false
gem 'selenium-webdriver'
gem 'simplecov', require: false
gem 'tzinfo-data'
gem 'vcr'
end

group :development do
Expand All @@ -64,6 +55,18 @@ group :development do
gem 'spring'
end

group :test do
gem 'capybara_minitest_spec'
gem 'm'
gem 'minitest-rails', '~> 6.0'
gem 'minitest-reporters'
# gem 'minitest-spec-rails'
gem 'mocha'
gem 'selenium-webdriver'
gem 'simplecov', '0.22.0'
gem 'vcr'
end

# TODO: For running the app locally for testing you can set this to your local path
# gem 'data_services_api', '~> 1.4.0', path: '~/Epimorphics/shared/data_services_api/'
# gem 'json_rails_logger', '~> 1.0.0', path: '~/Epimorphics/shared/json-rails-logger/'
Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ GEM
nokogiri (1.13.10)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
oj (3.13.11)
oj (3.14.2)
parallel (1.22.1)
parser (3.1.1.0)
ast (~> 2.4.1)
Expand Down Expand Up @@ -300,7 +300,7 @@ GEM
sentry-ruby (5.7.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
sexp_processor (4.16.0)
simplecov (0.21.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
Expand Down Expand Up @@ -385,7 +385,7 @@ DEPENDENCIES
minitest-reporters
mocha
nokogiri (= 1.13.10)
oj
oj (= 3.14.2)
prometheus-client (~> 4.0)
puma
rails (~> 6.0)
Expand All @@ -395,7 +395,7 @@ DEPENDENCIES
sass-rails
selenium-webdriver
sentry-rails (~> 5.7)
simplecov
simplecov (= 0.22.0)
spring
tzinfo-data
uglifier (>= 1.3.0)
Expand All @@ -405,4 +405,4 @@ DEPENDENCIES
yajl-ruby

BUNDLED WITH
2.4.20
2.4.8
19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: assets clean image lint publish realclean run tag test vars
.PHONY: assets check clean image lint publish realclean run tag test vars

ACCOUNT?=$(shell aws sts get-caller-identity | jq -r .Account)
ALPINE_VERSION?=3.13
Expand All @@ -7,7 +7,6 @@ BUNDLER_VERSION?=$(shell tail -1 Gemfile.lock | tr -d ' ')
ECR?=${ACCOUNT}.dkr.ecr.eu-west-1.amazonaws.com
GPR_OWNER?=epimorphics
NAME?=$(shell awk -F: '$$1=="name" {print $$2}' deployment.yaml | sed -e 's/[[:blank:]]//g')
SHORTNAME?=$(shell echo ${NAME} | cut -f2 -d/)
PAT?=$(shell read -p 'Github access token:' TOKEN; echo $$TOKEN)
PORT?=3002
RUBY_VERSION?=$(shell cat .ruby-version)
Expand Down Expand Up @@ -38,19 +37,21 @@ ${GITHUB_TOKEN}:
@echo ${PAT} > ${GITHUB_TOKEN}

assets:
@./bin/bundle config set --local without 'development'
@./bin/bundle install
@yarn 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} ...
@echo Building ${NAME}:${TAG} ...
@docker build \
--build-arg ALPINE_VERSION=${ALPINE_VERSION} \
--build-arg RUBY_VERSION=${RUBY_VERSION} \
Expand All @@ -60,7 +61,7 @@ image: auth
--build-arg git_commit_hash=${COMMIT} \
--build-arg github_run_number=${GITHUB_RUN_NUMBER} \
--build-arg image_name=${NAME} \
--tag ${REPO}:${TAG} \
--tag ${NAME}:${TAG} \
.
@echo Done.

Expand All @@ -69,6 +70,7 @@ lint: assets

publish: image
@echo Publishing image: ${REPO}:${TAG} ...
@docker tag ${NAME}:${TAG} ${REPO}:${TAG} 2>&1
@docker push ${REPO}:${TAG} 2>&1
@echo Done.

Expand All @@ -77,7 +79,7 @@ realclean: clean

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}
@docker run -p ${PORT}:3000 -e API_SERVICE_URL=${API_SERVICE_URL} --network dnet --rm --name ${SHORTNAME} ${NAME}:${TAG}

server: assets start
@export SECRET_KEY_BASE=$(./bin/rails secret)
Expand All @@ -91,7 +93,8 @@ tag:
@echo ${TAG}

test: assets
@./bin/rails test
@echo "Running unit tests ..."
@./bin/bundle exec rake test

vars:
@echo "Docker: ${REPO}:${TAG}"
Expand All @@ -102,10 +105,10 @@ vars:
@echo "ECR = ${ECR}"
@echo "GPR_OWNER = ${GPR_OWNER}"
@echo "NAME = ${NAME}"
@echo "SHORTNAME = ${SHORTNAME}"
@echo "RUBY_VERSION = ${RUBY_VERSION}"
@echo "SHORTNAME = ${SHORTNAME}"
@echo "STAGE = ${STAGE}"
@echo "COMMIT = ${COMMIT}"
@echo "REPO = ${REPO}"
@echo "TAG = ${TAG}"
@echo "VERSION = ${VERSION}"
1 change: 0 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def detailed_request_log(duration)
end
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize


# 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
Expand Down
2 changes: 1 addition & 1 deletion app/lib/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Version
MAJOR = 1
MINOR = 7
PATCH = 3
PATCH = 4
SUFFIX = nil
VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}#{SUFFIX && ".#{SUFFIX}"}"
end
6 changes: 3 additions & 3 deletions app/presenters/print_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ class PrintPresenter < DownloadPresenter # rubocop:disable Metrics/ClassLength
DownloadColumn.new(
label: I18n.t('browse.print.reporting_period').html_safe,
format: lambda do |row|
key = row['ukhpi:refPeriodDuration'].first == 3 ? 'quarterly' : 'monthly'
key = row['ukhpi:refPeriodDuration'].try(:first) == 3 ? 'quarterly' : 'monthly'
val = I18n.t("browse.print.#{key}")
"<div class='u-text-centre'>#{val}</div>".html_safe
end
),
DownloadColumn.new(
label: I18n.t('statistic.volume'),
format: lambda do |row|
val = row['ukhpi:salesVolume'].first
val = row['ukhpi:salesVolume'].try(:first)
"<div class='u-text-right'>#{val}</div>".html_safe
end
)
Expand Down Expand Up @@ -127,7 +127,7 @@ def statistic_indicator_columns(stat) # rubocop:disable Metrics/MethodLength
stat: stat,
sep: '<br />',
format: lambda do |row|
val = row["ukhpi:#{ind&.root_name}#{stat.root_name}"].first
val = row["ukhpi:#{ind&.root_name}#{stat.root_name}"].try(:first)
ValueFormatter.format(val,
slug: ind&.root_name,
template: "<div class='u-text-right'>%<formatted>s</div>")
Expand Down
8 changes: 5 additions & 3 deletions app/views/layouts/print.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
%meta{ name: 'viewport', content: 'width=device-width, initial-scale=1, shrink-to-fit=no' }
%title
= I18n.t('common.header.app_title')
- if Rails.env.production?
= render partial: 'common/google-analytics'
= csrf_meta_tags
= stylesheet_link_tag 'application', media: 'all'
= csrf_meta_tags
= render partial: 'common/favicons'

- if @preferences
Expand All @@ -25,8 +27,8 @@
.header-wrapper
.header-global
.header-logo
%a.content{ href: '/app/ukhpi', title: 'UK HPI' }
= image_tag('ukhpi-icon.png', srcset: image_path('ukhpi-icon.svg'))
%a.content{ href: "#{Rails.application.config.relative_url_root}", title: t('common.header.home_link') }
= image_tag('ukhpi-icon.png', srcset: image_path('ukhpi-icon.svg'), alt: '')
.header-proposition
.content
%nav#proposition-menu
Expand Down
Loading

0 comments on commit eb508b9

Please sign in to comment.