Class: Octo::Conversions
- Inherits:
-
Object
- Object
- Octo::Conversions
- Includes:
- MongoMapper::Document, Record
- Defined in:
- lib/octocore-mongo/models/enterprise/conversions.rb
Overview
The conversions store
Constant Summary collapse
- NEWSFEED =
Types of conversions
0
- PUSH_NOTIFICATION =
1
- EMAIL =
2
Constants included from MongoMapper::Document
MongoMapper::Document::DUMP_ATTRS
Class Method Summary collapse
- .data(enterprise_id, type, ts = 3.days.ago..Time.now.floor) ⇒ Object
-
.types ⇒ Hash
Fetches the types of conversions possible.
Methods included from Record
Methods included from MongoMapper::Document
#marshal_dump, #marshal_load, redis, update_cache_config
Class Method Details
.data(enterprise_id, type, ts = 3.days.ago..Time.now.floor) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/octocore-mongo/models/enterprise/conversions.rb', line 36 def data( enterprise_id, type, ts = 3.days.ago..Time.now.floor) args = { enterprise_id: enterprise_id, type: type, ts: ts } res = self.where(args) if res.count > 0 res.first else res = [] e = Octo::Enterprise.find_by_id(enterprise_id) if e.fakedata? if ts.class == Range ts_begin = ts.begin.floor ts_end = ts.end.floor ts_begin.to(ts_end, 1.day).each do |_ts| _args = args.merge( ts: _ts, value: rand(10.0..67.0)) res << self.new(_args).save! end elsif ts.class == Time args.merge!({ value: rand(10.0..67.0) }) res << self.new(args).save! end end end res end |
.types ⇒ Hash
Fetches the types of conversions possible
28 29 30 31 32 33 34 |
# File 'lib/octocore-mongo/models/enterprise/conversions.rb', line 28 def types { 'Newsfeed' => Octo::Conversions::NEWSFEED, 'Notification' => Octo::Conversions::PUSH_NOTIFICATION, # 'Email' => Octo::Conversions::EMAIL } end |