diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-09-13 10:30:20 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-09-13 10:30:20 +0100 |
commit | a622b31a33658696525ad675cdeb1e433f2a7c8b (patch) | |
tree | 3ecded4ccfc0263b26d01558b0836e561b075713 /app/controllers/admin_request_controller.rb | |
parent | 65b1d387a135ff027d2dfc2972ad97d2b3d85288 (diff) | |
parent | 9c635e7908f33f80a93d140dc54061d63a75ceba (diff) |
Merge branch 'feature/faster-admin-old-unclassified' into develop
Diffstat (limited to 'app/controllers/admin_request_controller.rb')
-rw-r--r-- | app/controllers/admin_request_controller.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index c5abf8769..7cf23e61e 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -16,12 +16,25 @@ class AdminRequestController < AdminController def list @query = params[:query] - @info_requests = InfoRequest.paginate :order => "created_at desc", :page => params[:page], :per_page => 100, + @info_requests = InfoRequest.paginate :order => "created_at desc", + :page => params[:page], + :per_page => 100, :conditions => @query.nil? ? nil : ["lower(title) like lower('%'||?||'%')", @query] end def list_old_unclassified - @info_requests = InfoRequest.find_old_unclassified(:conditions => ["prominence = 'normal'"]) + @info_requests = WillPaginate::Collection.create((params[:page] or 1), 50) do |pager| + info_requests = InfoRequest.find_old_unclassified(:conditions => ["prominence = 'normal'"], + :limit => pager.per_page, + :offset => pager.offset) + # inject the result array into the paginated collection: + pager.replace(info_requests) + + unless pager.total_entries + # the pager didn't manage to guess the total count, do it manually + pager.total_entries = InfoRequest.count_old_unclassified(:conditions => ["prominence = 'normal'"]) + end + end end def show |