Class: Jinda::Xmain

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/generators/jinda/templates/app/models/jinda/xmain.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get(xid) ⇒ Object

number of xmains on the specified date



24
25
26
# File 'lib/generators/jinda/templates/app/models/jinda/xmain.rb', line 24

def self.get(xid)
  find_by(xid:xid)
end

.number(d) ⇒ Object



30
31
32
# File 'lib/generators/jinda/templates/app/models/jinda/xmain.rb', line 30

def self.number(d)
  all(:conditions=>['DATE(created_at) =?', d.to_date]).count
end

.search(q, page, per_page = 10) ⇒ Object



33
34
35
36
37
# File 'lib/generators/jinda/templates/app/models/jinda/xmain.rb', line 33

def self.search(q, page, per_page=10)
  paginate :per_page=>per_page, :page => page, :conditions =>
    ["LOWER(xvars) LIKE ?", "%#{q}%" ],
    :order=>'created_at DESC'
end

Instance Method Details

#assign_xidObject



27
28
29
# File 'lib/generators/jinda/templates/app/models/jinda/xmain.rb', line 27

def assign_xid
  self.xid = Param.gen(:xid)
end