diff options
| author | hukl <contact@smyck.org> | 2009-12-01 21:05:45 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-12-01 21:09:56 +0100 |
| commit | 7e46b0ce0f2216d4a53cf9e633fcfed3cd421c7c (patch) | |
| tree | 12274eeac157509e836d8961ff1dc0ff12594b06 | |
| parent | 502a1bd51e46202b41d8978b0a455a07653a03d8 (diff) | |
refactored the Page.aggregate to instanciate a lot less AR objects. Its actually instanciating only the ones being displayed. Still over 150 but still a massive improvement compared to over 1500 before.
| -rw-r--r-- | app/models/page.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/app/models/page.rb b/app/models/page.rb index 00832bd..37b221e 100644 --- a/app/models/page.rb +++ b/app/models/page.rb | |||
| @@ -62,15 +62,17 @@ class Page < ActiveRecord::Base | |||
| 62 | 62 | ||
| 63 | options = defaults.merge options | 63 | options = defaults.merge options |
| 64 | 64 | ||
| 65 | Page.heads.find_tagged_with( | 65 | Page.heads.paginate( |
| 66 | options[:tags].gsub(/\s/, ", "), | 66 | find_options_for_find_tagged_with( |
| 67 | :match_all => true, | 67 | options[:tags].gsub(/\s/, ","), :match_all => true |
| 68 | :order => "#{options[:order_by]} #{options[:order_direction]}" | 68 | ).merge( |
| 69 | ).paginate(:page=>page, :per_page => options[:limit]) | 69 | :page => page, |
| 70 | 70 | :per_page => options[:limit], | |
| 71 | :order => "#{options[:order_by]} #{options[:order_direction]}" | ||
| 72 | ) | ||
| 73 | ) | ||
| 71 | end | 74 | end |
| 72 | 75 | ||
| 73 | |||
| 74 | def self.custom_templates | 76 | def self.custom_templates |
| 75 | files = Dir.entries(FULL_PUBLIC_TEMPLATE_PATH).select do |x| | 77 | files = Dir.entries(FULL_PUBLIC_TEMPLATE_PATH).select do |x| |
| 76 | x if x.gsub!(".html.erb", "") | 78 | x if x.gsub!(".html.erb", "") |
