OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / models / resource_picture.rb
index e087b99..42c8eb6 100644 (file)
@@ -24,6 +24,34 @@ class ResourcePicture < Peta::Content
   validates :license_group_settings, :boost => {:boost_name => :license_group}
   validates :credit_picture_settings, :boost => {:boost_name => :credit_picture}
   
+  scope :find_index, -> do
+    self.all
+  end
+  
+  scope :find_private, -> (operators) do 
+    where(artist_id: operators.artist.id)
+  end
+  
+  scope :find_by_original_picture, -> (original_picture_id) do 
+    find_index.where(original_picture_id: original_picture_id)
+  end
+  
+  scope :find_by_license_group, -> (license_group_id) do 
+    find_index.where(license_group_id: license_group_id)
+  end
+  
+  scope :find_by_license, -> (license_id) do 
+    find_index.where(license_id: license_id)
+  end
+  
+  scope :find_by_artist, -> (artist_id) do 
+    find_index.where(artist_id: artist_id)
+  end
+  
+  scope :find_by_md5, -> (md5) do 
+    find_index.where(md5: md5)
+  end
+  
   def self.pickup_item_name
     Picture.item_name
   end
@@ -235,7 +263,7 @@ class ResourcePicture < Peta::Content
   end
   
   def self.remake_all
-    ResourcePicture.find(:all).each do |resource_picture|
+    ResourcePicture.find_each do |resource_picture|
       resource_picture.boosts 'post'
       full = resource_picture.restore 'full'
       imager = PettanImager.load full