Class: Report
- Inherits:
-
Object
- Object
- Report
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/app/models/report.rb
Constant Summary collapse
- PER_PAGE =
20
Class Method Summary collapse
- .all ⇒ Object
- .clear ⇒ Object
- .for_homepage(args) ⇒ Object
- .list(conditions = { :is_trash => false }) ⇒ Object
- .not_tagged ⇒ Object
- .paginates_per ⇒ Object
Instance Method Summary collapse
Class Method Details
.all ⇒ Object
77 78 79 |
# File 'lib/app/models/report.rb', line 77 def self.all self.where( :is_public => true, :is_trash => false ).order_by( :created_at => :desc ) end |
.clear ⇒ Object
130 131 132 133 134 |
# File 'lib/app/models/report.rb', line 130 def self.clear if Rails.env.test? self.unscoped.each { |r| r.remove } end end |
.for_homepage(args) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/app/models/report.rb', line 85 def self.for_homepage args begin tag_ids = args[:main_tag]..map { |tag| tag._id } + [ args[:main_tag]._id ] return Report.where( :tag_id.in => tag_ids ).page args[:page] rescue return Report.page args[:page] end end |
.list(conditions = { :is_trash => false }) ⇒ Object
63 64 65 66 |
# File 'lib/app/models/report.rb', line 63 def self.list conditions = { :is_trash => false } out = self.where( conditions ).order_by( :name => :asc ).limit( 100 ) [['', nil]] + out.map { |item| [ item.name, item.id ] } end |
.not_tagged ⇒ Object
81 82 83 |
# File 'lib/app/models/report.rb', line 81 def self.not_tagged Report.where( :tag_id => nil, :city => nil ) end |
.paginates_per ⇒ Object
69 70 71 |
# File 'lib/app/models/report.rb', line 69 def self.paginates_per self::PER_PAGE end |
Instance Method Details
#venue ⇒ Object
73 74 75 |
# File 'lib/app/models/report.rb', line 73 def venue return self.venues[0] || nil end |