diff options
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/page.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/app/models/page.rb b/app/models/page.rb index 0fcb4a87..3d02e9f5 100644 --- a/app/models/page.rb +++ b/app/models/page.rb | |||
| @@ -4,4 +4,39 @@ class Page < ActiveRecord::Base | |||
| 4 | 4 | ||
| 5 | acts_as_list :column => :revision, :scope => :node_id | 5 | acts_as_list :column => :revision, :scope => :node_id |
| 6 | 6 | ||
| 7 | |||
| 8 | # <aggregate | ||
| 9 | # flags="updates pressemitteilungen" | ||
| 10 | # path="updates/2009" | ||
| 11 | # limit="20" | ||
| 12 | # order_by="published_at" | ||
| 13 | # order_direction="DESC" | ||
| 14 | # /> | ||
| 15 | def self.aggregate options | ||
| 16 | |||
| 17 | defaults = { | ||
| 18 | :flags => "", | ||
| 19 | :path => "", | ||
| 20 | :limit => 20, | ||
| 21 | :order_by => "id", | ||
| 22 | :order_direction => "ASC" | ||
| 23 | } | ||
| 24 | |||
| 25 | options = defaults.merge options | ||
| 26 | |||
| 27 | pages = Page.all( | ||
| 28 | :limit => options[:limit], | ||
| 29 | :order => "#{options[:order_by]} #{options[:order_direction]}" | ||
| 30 | ) | ||
| 31 | end | ||
| 7 | end | 32 | end |
| 33 | |||
| 34 | |||
| 35 | named_scope :flagged_as, lambda { |flags| | ||
| 36 | conditions = {} | ||
| 37 | flags.each do |flag| | ||
| 38 | conditions[flag] = true | ||
| 39 | end | ||
| 40 | |||
| 41 | { :conditions => conditions } | ||
| 42 | } \ No newline at end of file | ||
