Class: Catptcha::PhotoGroup

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/catptcha/photo_group.rb

Overview

  • flickr_group_id

  • photos_updated_at

  • photos_count

Class Method Summary collapse

Class Method Details

.paginate(page) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/catptcha/photo_group.rb', line 18

def self.paginate(page)
  Catptcha::Photo.paginate(
    :conditions => {:photo_group_id => all.map(&:id)},
    :order => 'photo_group_id',
    :page => page,
    :per_page => 110
  )
end

.photos_countObject



14
15
16
# File 'lib/catptcha/photo_group.rb', line 14

def self.photos_count
  sum(:photos_count)
end

.random(count) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/catptcha/photo_group.rb', line 27

def self.random count
  Catptcha::Photo.all(
    :conditions => ['photo_group_id in (?)', all.map(&:id)],
    :order => 'catptcha_photos.key ASC',
    :offset => rand(photos_count-count).to_i,
    :limit => count
  )
end