Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release Candidate v.1.7.6 #213

Merged
merged 20 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a1785b0
fix: added additional `rescue_from` clauses
jonrandahl Mar 7, 2024
f20a603
chore: removing erroneous files
jonrandahl Mar 7, 2024
771470c
feat: addition of 403 error template
jonrandahl Mar 7, 2024
7290305
fix: Removed erroneous method from StandardError rescue
jonrandahl Mar 7, 2024
7970c9c
fix: updated .gitignore to ensure expected files are included!
jonrandahl Mar 7, 2024
2f71e2b
build: updated Makefile targets
jonrandahl Mar 7, 2024
4ef491c
build: resolve build error
jonrandahl Mar 7, 2024
796c661
build: resolve build error in docker container
jonrandahl Mar 7, 2024
45d559e
Merge pull request #209 from epimorphics/spike/resolve-missing-error-…
jonrandahl Mar 7, 2024
6c8c09c
fix: resolve app failures
jonrandahl Mar 7, 2024
62f9564
Merge pull request #210 from epimorphics/spike/resolve-app-failures
jonrandahl Mar 7, 2024
89bdde6
fix: resolving missing template rescue
jonrandahl Mar 8, 2024
a21c44d
chore: rearranged for readability
jonrandahl Mar 8, 2024
5dfe39e
docs: Updated CHANGELOG
jonrandahl Mar 8, 2024
e36cf54
build: incremented Patch Version cadence for release
jonrandahl Mar 8, 2024
4fba3e1
chore: Fixed typo in latest CHANGELOG entry
jonrandahl Mar 8, 2024
40e1c4b
Merge pull request #211 from epimorphics/spike/resolve-missing-templa…
jonrandahl Mar 8, 2024
0944a1f
fix: resolves missing template error
jonrandahl Mar 8, 2024
3f6cbe4
style: Unnecessary disabling of `Metrics/PerceivedComplexity`
jonrandahl Mar 8, 2024
0836777
Merge pull request #212 from epimorphics/spike/resolve-missing-templa…
jonrandahl Mar 8, 2024
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
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
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.

57 changes: 0 additions & 57 deletions public/500.html

This file was deleted.

Loading
Loading