Skip to content

Commit

Permalink
Merge pull request #214 from epimorphics/task/release-v1.7.6
Browse files Browse the repository at this point in the history
Release v1.7.6
  • Loading branch information
jonrandahl authored Mar 8, 2024
2 parents 448f29a + a44ef49 commit 6229aa3
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 199 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
/db/*.sqlite3
/db/*.sqlite3-journal
/log/*.log
/tmp
/public/packs
/public/packs-test
/tmp
/public/assets/
coverage/
fc.json
fc_simple.json
index-names.txt
index.json
public/
public/assets/
tags
tags
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

This app allows the user to explore HMLR price-paid open linked data.

## 1.7.6 - 2024-03-08

- (Jon) Updated the application_controller to include an
`ActionView::MissingTemplate` rescue to ensure the correct 404 template is
displayed when a template is not found
[GH-138](https://github.com/epimorphics/hmlr-linked-data/issues/138)

## 1.7.5 - 2023-11-27

- (Jon) Updated the `lr_common_styles` gem to the latest 1.9.3 patch release.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apk add --update \
nodejs \
tzdata \
&& rm -rf /var/cache/apk/* \
&& gem update --system \
&& gem update --system 3.2.3 \
&& gem install bundler:$BUNDLER_VERSION \
&& bundle config --global frozen 1

Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ gem 'uglifier', '>= 1.3.0'
# gem 'therubyracer', platforms: :ruby
gem 'libv8-node', '>= 16.10.0.0'

# lock down the version of rubygems-update to avoid issues with rubygems
gem 'rubygems-update', '~> 3.4', '>= 3.4.22'

gem 'jbuilder'
gem 'jquery-rails'

Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ GEM
ruby2_keywords (0.0.5)
ruby_parser (3.19.0)
sexp_processor (~> 4.16)
rubygems-update (3.4.22)
rubyzip (2.3.2)
sass (3.7.4)
sass-listen (~> 4.0.0)
Expand Down Expand Up @@ -398,6 +399,7 @@ DEPENDENCIES
rb-readline
rubocop
rubocop-rails
rubygems-update (~> 3.4, >= 3.4.22)
sass-rails
sdoc
sentry-rails (~> 5.2)
Expand Down
18 changes: 15 additions & 3 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 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
Expand Down Expand Up @@ -37,13 +37,16 @@ ${BUNDLE_CFG}: ${GITHUB_TOKEN}
${GITHUB_TOKEN}:
@echo ${PAT} > ${GITHUB_TOKEN}

assets:
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 || :

Expand All @@ -65,6 +68,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
Expand All @@ -89,7 +98,10 @@ tag:
@echo ${TAG}

test: assets
@./bin/rails test
@echo "Running unit tests ..."
@./bin/rails test:unit
@echo "Running system tests ..."
@./bin/rails test:system

vars:
@echo "Docker: ${REPO}:${TAG}"
Expand Down
35 changes: 21 additions & 14 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,35 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :null_session

before_action :set_phase, :change_default_caching_policy
around_action :log_request_result

def set_phase
@phase = :released
end

around_action :log_request_result
# * Set cache control headers for HMLR apps to be public and cacheable
# * Price Paid Data uses a time limit of 5 minutes (300 seconds)
# Sets the default `Cache-Control` header for all requests,
# unless overridden in the action
def change_default_caching_policy
expires_in 5.minutes, public: true, must_revalidate: true if Rails.env.production?
end

def log_request_result
start = Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond)
yield
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond) - start
detailed_request_log(duration)
end

# Handle specific types of exceptions and render the appropriate error page
# or attempt to render a generic error page if no specific error page exists
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, with: :render_exception
rescue_from ActionController::RoutingError, with: :render404
rescue_from ActionController::InvalidCrossOriginRequest, with: :render403
rescue_from ActionController::RoutingError, with: :render404
rescue_from ActionController::BadRequest, with: :render400
rescue_from ActionView::MissingTemplate, with: :render404
rescue_from Exception, with: :render_exception
end

def render_exception(exception)
Expand All @@ -40,6 +52,10 @@ def render_exception(exception)
end
end

def render_400(_exception = nil) # rubocop:disable Naming/VariableNumber
render_error(400)
end

def render_404(_exception = nil) # rubocop:disable Naming/VariableNumber
render_error(404)
end
Expand All @@ -53,9 +69,8 @@ def render_error(status)

respond_to do |format|
format.html { render_html_error_page(status) }
format.all do
render nothing: true, status: status
end
# Anything else returns the status as human readable plain string
format.all { render plain: Rack::Utils::HTTP_STATUS_CODES[status].to_s, status: status }
end
end

Expand Down Expand Up @@ -102,12 +117,4 @@ def detailed_request_log(duration)
def instrument_internal_error(exception)
ActiveSupport::Notifications.instrument('internal_error.application', exception: exception)
end

# * Set cache control headers for HMLR apps to be public and cacheable
# * Price Paid Data uses a time limit of 5 minutes (300 seconds)
# Sets the default `Cache-Control` header for all requests,
# unless overridden in the action
def change_default_caching_policy
expires_in 5.minutes, public: true, must_revalidate: true if Rails.env.production?
end
end
5 changes: 3 additions & 2 deletions app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def index
create
end

# rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity
# rubocop:disable Metrics/MethodLength
def create
@preferences = UserPreferences.new(params)

Expand All @@ -26,11 +26,12 @@ def create
end
rescue StandardError => e
e = e.cause || e

status = case e
when MalformedSearchError, ArgumentError
:bad_request
else
e.status || :internal_server_error
:internal_server_error
end

render_error_page(e, e.message, status)
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 = 5
PATCH = 6
SUFFIX = nil
VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}#{SUFFIX && ".#{SUFFIX}"}"
end
2 changes: 1 addition & 1 deletion deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: epimorphics/ppd-explorer
key: ppd
deployments:
- branch: "prod"
deploy: "prod"
# deploy: "prod"
publish: "prod"
- branch: "preprod"
deploy: "preprod"
Expand Down
58 changes: 0 additions & 58 deletions public/404.html

This file was deleted.

58 changes: 0 additions & 58 deletions public/422.html

This file was deleted.

Loading

0 comments on commit 6229aa3

Please sign in to comment.