OSDN Git Service

t#32471:add profiles
[pettanr/pettanr.git] / app / models / scroll.rb
index b51aff3..0768000 100644 (file)
@@ -110,6 +110,20 @@ class Scroll < ActiveRecord::Base
     Kaminari.paginate_array(Array.new(Scroll.where(self.himlist_where(au)).count, nil)).page(page).per(page_size)
   end
   
+  def self.list_by_panel panel_id, roles, page = 1, page_size = self.default_page_size
+    self.where(ScrollPanel.list_by_panel_where(panel_id)).includes(
+      {:scroll_panels => {}}
+    ).order('scroll_panels.updated_at desc').offset((page -1) * page_size).limit(page_size)
+  end
+  
+  def self.list_by_author_where author_id
+    ['scrolls.author_id = ?', author_id]
+  end
+  
+  def self.list_by_author author_id, roles, page = 1, page_size = self.default_page_size
+    self.where(self.list_by_author_where(author_id)).includes(self.list_opt).order('scrolls.updated_at desc').offset((page -1) * page_size).limit(page_size)
+  end
+  
   def self.list_opt
     {:scroll_panels => {:panel => {}}, :author => {} }
   end