diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-01-28 16:33:02 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-01-28 16:33:02 +0000 |
commit | 89a8fd2ce9880ae0f194733991aa93e447f0ba73 (patch) | |
tree | 7fd691a4f7cbd3f1aff61dd91f056a16478d5291 /app/models/info_request.rb | |
parent | 90fd29903b9db724c941b6e6efa39f41313e8825 (diff) | |
parent | df0583a94c6a3ce7ded818cb46688b7edc928302 (diff) |
Merge branch 'feature/cache-request-lists' into rails-3-develop
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r-- | app/models/info_request.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 4eb64dc13..eadb66d54 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -1232,6 +1232,23 @@ public return [xapian_similar, xapian_similar_more] end + def InfoRequest.request_list(filters, page, per_page, max_results) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], + InfoRequestEvent.make_query_from_params(filters), + :offset => (page - 1) * per_page, + :limit => 25, + :sort_by_prefix => 'created_at', + :sort_by_ascending => true, + :collapse_by_prefix => '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].min + return { :results => list_results, + :matches_estimated => matches_estimated, + :show_no_more_than => show_no_more_than } + end + def InfoRequest.recent_requests request_events = [] request_events_all_successful = false |