diff options
author | Johan Sørensen <johan@johansorensen.com> | 2009-12-15 10:30:26 +0100 |
---|---|---|
committer | Johan Sørensen <johan@johansorensen.com> | 2009-12-15 10:30:48 +0100 |
commit | b922abbbf5acec147bfd1fde78ac041e5c6deaa6 (patch) | |
tree | 033743ff796f9e60e2acc16a36122df0db1eba38 | |
parent | f89f0ca1ffa69c2985ddfb68d9260f0a07109872 (diff) | |
download | gitorious-mainline-outdated-b922abbbf5acec147bfd1fde78ac041e5c6deaa6.zip gitorious-mainline-outdated-b922abbbf5acec147bfd1fde78ac041e5c6deaa6.tar.gz gitorious-mainline-outdated-b922abbbf5acec147bfd1fde78ac041e5c6deaa6.tar.bz2 |
Cheat with the FeedItem pagination on the ~user page
If we just assume there's always one more page we have to waste time
querying for the total feeditems
-rw-r--r-- | app/models/user.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 553846d..9518192 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -378,11 +378,13 @@ class User < ActiveRecord::Base end def paginated_events_in_watchlist(pagination_options = {}) - watched_event_ids = feed_items.paginate({ - :order => "created_at desc" - }.merge(pagination_options)).map(&:event_id) - Event.paginate(watched_event_ids, - {:order => "created_at desc"}.merge(pagination_options)) + watched = feed_items.paginate({ + :order => "created_at desc", + :total_entries => FeedItem.per_page+(FeedItem.per_page+1) + }.merge(pagination_options)) + items = WillPaginate::Collection.new(watched.current_page, watched.per_page, + watched.total_entries) + items.replace(Event.find(watched.map(&:event_id), {:order => "created_at desc"})) end protected |