Class: Report

Inherits:
Object
  • Object
show all
Includes:
Ish::Utils, Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/report.rb

Constant Summary collapse

PER_PAGE =
10

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ish::Utils

#export

Class Method Details

.allObject



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

.clearObject



80
81
82
83
84
# File 'lib/report.rb', line 80

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_perObject



72
73
74
# File 'lib/report.rb', line 72

def self.paginates_per
  self::PER_PAGE
end

Instance Method Details

#export_fieldsObject



94
95
96
# File 'lib/report.rb', line 94

def export_fields
  %w| name descr |
end

#is_premiumObject



88
89
90
# File 'lib/report.rb', line 88

def is_premium
  premium_tier > 0
end

#item_typeObject

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

Returns:

  • (Boolean)


91
# File 'lib/report.rb', line 91

def premium?; is_premium; end

#premium_tierObject

copy-paste



87
# File 'lib/report.rb', line 87

field :premium_tier, type: Integer, default: 0