diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-01-15 16:05:25 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-01-15 16:05:25 +0000 |
commit | d1cac849b5c74e4f0d35b193ad24eed1d6b66af6 (patch) | |
tree | cb153b82b3e1d451be2d299b6114c99b6610b173 /app/controllers/request_controller.rb | |
parent | f25df72186683e54dd10fd5aa94e1e26dff8ea92 (diff) | |
parent | 7cc8cae3a669fc5de91d6bc23812c265e8af4c93 (diff) |
Merge branch 'release/0.6.9'
Diffstat (limited to 'app/controllers/request_controller.rb')
-rw-r--r-- | app/controllers/request_controller.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index d8c34c2dd..970dfca45 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -139,6 +139,11 @@ class RequestController < ApplicationController short_cache @per_page = 25 @page = (params[:page] || "1").to_i + + # Later pages are very expensive to load + if @page > MAX_RESULTS / PER_PAGE + raise ActiveRecord::RecordNotFound.new("Sorry. No pages after #{MAX_RESULTS / PER_PAGE}.") + end @info_request = InfoRequest.find_by_url_title!(params[:url_title]) raise ActiveRecord::RecordNotFound.new("Request not found") if @info_request.nil? @@ -148,6 +153,8 @@ class RequestController < ApplicationController end @xapian_object = ::ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events, :offset => (@page - 1) * @per_page, :limit => @per_page, :collapse_by_prefix => 'request_collapse') + @matches_estimated = @xapian_object.matches_estimated + @show_no_more_than = (@matches_estimated > MAX_RESULTS) ? MAX_RESULTS : @matches_estimated if (@page > 1) @page_desc = " (page " + @page.to_s + ")" |