Class: Report
- Inherits:
-
Object
- Object
- Report
- Includes:
- Ish::Utils, 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
- #export_fields ⇒ Object
- #is_premium ⇒ Object
-
#item_type ⇒ Object
Can be one of: default (nil), longscroll, wordpress e.g.
- #premium? ⇒ Boolean
-
#premium_tier ⇒ Object
copy-paste.
- #venue ⇒ Object
Methods included from Ish::Utils
Class Method Details
.all ⇒ Object
87 88 89 |
# File 'lib/report.rb', line 87 def self.all self.where( :is_public => true, :is_trash => false ).order_by( :created_at => :desc ) end |
.clear ⇒ Object
140 141 142 143 144 |
# File 'lib/report.rb', line 140 def self.clear if Rails.env.test? self.unscoped.each { |r| r.remove } end end |
.for_homepage(args) ⇒ Object
95 96 97 98 99 100 101 102 |
# File 'lib/report.rb', line 95 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
73 74 75 76 |
# File 'lib/report.rb', line 73 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
91 92 93 |
# File 'lib/report.rb', line 91 def self.not_tagged Report.where( :tag_ids => nil, :city => nil ) end |
.paginates_per ⇒ Object
79 80 81 |
# File 'lib/report.rb', line 79 def self.paginates_per self::PER_PAGE end |
Instance Method Details
#export_fields ⇒ Object
158 159 160 |
# File 'lib/report.rb', line 158 def export_fields %w| name descr | end |
#is_premium ⇒ Object
152 153 154 |
# File 'lib/report.rb', line 152 def is_premium premium_tier > 0 end |
#item_type ⇒ Object
Can be one of: default (nil), longscroll,
wordpress e.g. https://piousbox.com/wp-json/wp/v2/posts?slug=intro
ITEM_TYPES = %w| longscroll wordpress |
19 |
# File 'lib/report.rb', line 19 field :item_type, type: String |
#premium? ⇒ Boolean
155 |
# File 'lib/report.rb', line 155 def premium?; is_premium; end |
#premium_tier ⇒ Object
copy-paste
151 |
# File 'lib/report.rb', line 151 field :premium_tier, type: Integer, default: 0 |
#venue ⇒ Object
83 84 85 |
# File 'lib/report.rb', line 83 def venue return self.venues[0] || nil end |