summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorhukl <hukl@eight.local>2009-02-01 21:32:44 +0100
committerhukl <hukl@eight.local>2009-02-01 21:32:44 +0100
commitc1854b8b518bde82b80429636f73496a537c3ad5 (patch)
tree59492d905ba5edf4cb7f344ca68a98d8861ff3e0 /app/models
parenta660a7ee62e44314c12440d376166ccb0cf60d80 (diff)
added first careful steps for aggregation
Diffstat (limited to 'app/models')
-rw-r--r--app/models/page.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/app/models/page.rb b/app/models/page.rb
index 0fcb4a8..3d02e9f 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
7end 32end
33
34
35named_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