Class: Report
- Inherits:
-
Object
- Object
- Report
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/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
- #is_premium ⇒ Object
- #premium? ⇒ Boolean
-
#premium_tier ⇒ Object
copy-paste.
- #set_name_seo ⇒ Object
- #venue ⇒ Object
Class Method Details
.all ⇒ Object
79 80 81 |
# File 'lib/report.rb', line 79 def self.all self.where( :is_public => true, :is_trash => false ).order_by( :created_at => :desc ) end |
.clear ⇒ Object
135 136 137 138 139 |
# File 'lib/report.rb', line 135 def self.clear if Rails.env.test? self.unscoped.each { |r| r.remove } end end |
.for_homepage(args) ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/report.rb', line 87 def self.for_homepage args begin tag_ids = args[:main_tag]..map { |tag| tag._id } + [ args[:main_tag]._id ] return Report.where( :tag_ids.in => tag_ids ).page args[:page] rescue return Report.page args[:page] end end |
.list(conditions = { :is_trash => false }) ⇒ Object
65 66 67 68 |
# File 'lib/report.rb', line 65 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
83 84 85 |
# File 'lib/report.rb', line 83 def self.not_tagged Report.where( :tag_ids => nil, :city => nil ) end |
.paginates_per ⇒ Object
71 72 73 |
# File 'lib/report.rb', line 71 def self.paginates_per self::PER_PAGE end |
Instance Method Details
#is_premium ⇒ Object
147 148 149 |
# File 'lib/report.rb', line 147 def is_premium premium_tier > 0 end |
#premium? ⇒ Boolean
150 |
# File 'lib/report.rb', line 150 def premium?; is_premium; end |
#premium_tier ⇒ Object
copy-paste
146 |
# File 'lib/report.rb', line 146 field :premium_tier, type: Integer, default: 0 |
#set_name_seo ⇒ Object
97 98 99 |
# File 'lib/report.rb', line 97 def set_name_seo self.name_seo ||= self.name.gsub(' ', '-').gsub('.', '') end |
#venue ⇒ Object
75 76 77 |
# File 'lib/report.rb', line 75 def venue return self.venues[0] || nil end |