Commit 8acd760e5140f9ca5cfcccd17622dfccdfc6e21f
1 parent
1b944f75
Exists in
master
and in
29 other branches
Avoid paginating after loading everything.
Instead, use #paginate to find the records. (ActionItem1689)
Showing
2 changed files
with
16 additions
and
13 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -66,19 +66,21 @@ class CmsController < MyProfileController | @@ -66,19 +66,21 @@ class CmsController < MyProfileController | ||
66 | conditions = ['type != ?', 'RssFeed'] | 66 | conditions = ['type != ?', 'RssFeed'] |
67 | end | 67 | end |
68 | 68 | ||
69 | - @articles = @article.children.find( | ||
70 | - :all, | ||
71 | - :order => "case when type = 'Folder' then 0 when type ='Blog' then 1 else 2 end, updated_at DESC", | ||
72 | - :conditions => conditions | ||
73 | - ).paginate(:per_page => per_page, :page => params[:npage]) | 69 | + @articles = @article.children.paginate( |
70 | + :order => "case when type = 'Folder' then 0 when type ='Blog' then 1 else 2 end, updated_at DESC", | ||
71 | + :conditions => conditions, | ||
72 | + :per_page => per_page, | ||
73 | + :page => params[:npage] | ||
74 | + ) | ||
74 | end | 75 | end |
75 | 76 | ||
76 | def index | 77 | def index |
77 | @article = nil | 78 | @article = nil |
78 | - @articles = profile.top_level_articles.find( | ||
79 | - :all, | ||
80 | - :order => "case when type = 'Folder' then 0 when type ='Blog' then 1 else 2 end, updated_at DESC" | ||
81 | - ).paginate(:per_page => per_page, :page => params[:npage]) | 79 | + @articles = profile.top_level_articles.paginate( |
80 | + :order => "case when type = 'Folder' then 0 when type ='Blog' then 1 else 2 end, updated_at DESC", | ||
81 | + :per_page => per_page, | ||
82 | + :page => params[:npage] | ||
83 | + ) | ||
82 | render :action => 'view' | 84 | render :action => 'view' |
83 | end | 85 | end |
84 | 86 |
app/helpers/folder_helper.rb
@@ -4,10 +4,11 @@ module FolderHelper | @@ -4,10 +4,11 @@ module FolderHelper | ||
4 | 4 | ||
5 | def list_articles(articles, recursive = false) | 5 | def list_articles(articles, recursive = false) |
6 | if !articles.blank? | 6 | if !articles.blank? |
7 | - articles = articles.find( | ||
8 | - :all, | ||
9 | - :order => "updated_at DESC" | ||
10 | - ).paginate(:per_page => 10, :page => params[:npage]) | 7 | + articles = articles.paginate( |
8 | + :order => "updated_at DESC", | ||
9 | + :per_page => 10, | ||
10 | + :page => params[:npage] | ||
11 | + ) | ||
11 | 12 | ||
12 | render :file => 'shared/articles_list', :locals => {:articles => articles, :recursive => recursive} | 13 | render :file => 'shared/articles_list', :locals => {:articles => articles, :recursive => recursive} |
13 | else | 14 | else |