Skip to content

Commit

Permalink
Merge branch 'dev' into master-legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-hank committed Nov 21, 2020
2 parents bb8196b + 876fc53 commit db987f5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions app/controllers/notices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,29 @@ 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 }
format.json do
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
Expand Down

0 comments on commit db987f5

Please sign in to comment.