diff --git a/CHANGELOG.md b/CHANGELOG.md index b463eecbd..ea98b4a7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * [#630](https://github.com/berkmancenter/lumendatabase/pull/630) Updates caching strategy on home page to be more resilient across deploys. * [#630](https://github.com/berkmancenter/lumendatabase/pull/630) Improves documentation (Elasticsearch indexing, release procedures). +## [20.11a](https://github.com/berkmancenter/lumendatabase/releases/tag/2020.11a) - 2020-11-21 +### Changed + * Clean up the production log. + ## [20.11](https://github.com/berkmancenter/lumendatabase/releases/tag/2020.11) - 2020-11-11 ### Changed * Allow to customize the search index name during the `run_catchup_es_indexing` task. diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f00d29b5c..7cdd8a5fd 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -72,8 +72,9 @@ def store_action store_location_for(:user, request.fullpath) end - def resource_not_found(exception) - logger.error(exception) + def resource_not_found(exception = false) + logger404s = Logger.new("#{Rails.root}/log/#{Rails.env}_404s.log") + logger404s.error(exception) if exception respond_to do |format| format.html do diff --git a/app/controllers/notices_controller.rb b/app/controllers/notices_controller.rb index 6b4fedc03..111957b18 100644 --- a/app/controllers/notices_controller.rb +++ b/app/controllers/notices_controller.rb @@ -60,7 +60,7 @@ def create end def show - return unless (@notice = Notice.find(params[:id])) + return resource_not_found("Can't fing notice with id=#{params[:id]}") unless (@notice = Notice.find_by(id: params[:id])) respond_to do |format| format.html { show_render_html } @@ -68,15 +68,21 @@ def show render json: @notice, serializer: NoticeSerializerProxy, root: json_root_for(@notice.class) - end + end end end def feed - @recent_notices = Rails.cache.fetch( + notice_ids = Rails.cache.fetch( 'recent_notices', expires_in: 1.hour - ) { Notice.visible.recent } + ) do + @notices = Notice.visible.recent + @notices.pluck(:id) + end + + @recent_notices ||= Notice.where(id: notice_ids) + respond_to do |format| format.rss { render layout: false } end