diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-01-20 12:18:21 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-01-20 12:18:21 +0000 |
commit | 23e5ffe66cedbe0f4e7788c49ffd56dff94b1586 (patch) | |
tree | 7fa1dd7c34e583e441f66b11a1f4364c4ca693a3 /app/controllers/request_controller.rb | |
parent | c92892e3a4fdc3e339996fc4db737634b15894c8 (diff) | |
parent | a37e9f21f00af03d271cb40de7d849cb8941bc02 (diff) |
Merge branch 'wdtk' of github.com:sebbacon/alaveteli into wdtk
Diffstat (limited to 'app/controllers/request_controller.rb')
-rw-r--r-- | app/controllers/request_controller.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 7bc51bc28..0f980b43f 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -13,6 +13,9 @@ require 'open-uri' class RequestController < ApplicationController before_filter :check_read_only, :only => [ :new, :show_response, :describe_state, :upload_response ] protect_from_forgery :only => [ :new, :show_response, :describe_state, :upload_response ] # See ActionController::RequestForgeryProtection for details + + MAX_RESULTS = 500 + PER_PAGE = 25 @@custom_states_loaded = false begin @@ -155,11 +158,10 @@ class RequestController < ApplicationController if @view == "recent" return redirect_to request_list_all_path(:action => "list", :view => "all", :page => @page), :status => :moved_permanently end - - # Temporary patch - # Later pages are very expensive to load - if @page > 100 - raise "Sorry. No pages after 100 today." + + # 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 params[:latest_status] = @view @@ -170,6 +172,7 @@ class RequestController < ApplicationController xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse') @list_results = xapian_object.results.map { |r| r[:model] } @matches_estimated = xapian_object.matches_estimated + @show_no_more_than = (@matches_estimated > MAX_RESULTS) ? MAX_RESULTS : @matches_estimated end @title = @title + " (page " + @page.to_s + ")" if (@page > 1) |