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
unless doc.city.blank? city = City.find doc.city.id if defined?( doc.profile ) && doc.profile username = doc.profile.username || ‘anon’ else username = ‘<username>’ end n = Newsitem.new :report => doc, :username => username city.newsitems << n city.save city.touch end end end.
- .list(conditions = { :is_trash => false }) ⇒ 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.
Methods included from Ish::Utils
Class Method Details
.all ⇒ Object
76 77 78 |
# File 'lib/report.rb', line 76 def self.all self.where( :is_public => true, :is_trash => false ).order_by( :created_at => :desc ) end |
.clear ⇒ Object
unless doc.city.blank?
city = City.find doc.city.id
if defined?( doc.profile ) && doc.profile
username = doc.profile.username || 'anon'
else
username = '<username>'
end
n = Newsitem.new :report => doc, :username => username
city.newsitems << n
city.save
city.touch
end
end
end
114 115 116 117 118 |
# File 'lib/report.rb', line 114 def self.clear if Rails.env.test? self.unscoped.each { |r| r.remove } end end |
.list(conditions = { :is_trash => false }) ⇒ Object
66 67 68 69 |
# File 'lib/report.rb', line 66 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 |
.paginates_per ⇒ Object
72 73 74 |
# File 'lib/report.rb', line 72 def self.paginates_per self::PER_PAGE end |
Instance Method Details
#export_fields ⇒ Object
128 129 130 |
# File 'lib/report.rb', line 128 def export_fields %w| name descr | end |
#is_premium ⇒ Object
122 123 124 |
# File 'lib/report.rb', line 122 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
125 |
# File 'lib/report.rb', line 125 def premium?; is_premium; end |
#premium_tier ⇒ Object
copy-paste
121 |
# File 'lib/report.rb', line 121 field :premium_tier, type: Integer, default: 0 |