diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-04-07 12:58:54 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-04-07 12:58:54 +0100 |
commit | 06e13489e2afa36f2070f61fd68abb357c1d18b7 (patch) | |
tree | 454b66a828144f616e3675f553c7a0f396b8697e /app/controllers/public_body_controller.rb | |
parent | d2fd05bb203466187ec87479f78792f3e047ff45 (diff) | |
parent | cd0823a4bae3e98301e2eeea50c6d0f5c9c8e83d (diff) |
Merge branch 'master' into rails-3-develop
Diffstat (limited to 'app/controllers/public_body_controller.rb')
-rw-r--r-- | app/controllers/public_body_controller.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index cc3d0b64a..854e79a19 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -9,9 +9,17 @@ require 'confidence_intervals' require 'tempfile' class PublicBodyController < ApplicationController + + MAX_RESULTS = 500 # TODO: tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL def show long_cache + @page = get_search_page_from_params + requests_per_page = 25 + # Later pages are very expensive to load + if @page > MAX_RESULTS / requests_per_page + raise ActiveRecord::RecordNotFound.new("Sorry. No pages after #{MAX_RESULTS / requests_per_page}.") + end if MySociety::Format.simplify_url_part(params[:url_name], 'body') != params[:url_name] redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name], 'body'), :status => :moved_permanently return @@ -45,7 +53,7 @@ class PublicBodyController < ApplicationController # TODO: really should just use SQL query here rather than Xapian. sortby = "described" begin - @xapian_requests = perform_search([InfoRequestEvent], query, sortby, 'request_collapse') + @xapian_requests = perform_search([InfoRequestEvent], query, sortby, 'request_collapse', requests_per_page) if (@page > 1) @page_desc = " (page " + @page.to_s + ")" else |