Class: Octo::EngagementTime
- Inherits:
-
Object
- Object
- Octo::EngagementTime
- Includes:
- MongoMapper::Document
- Defined in:
- lib/octocore-mongo/models/enterprise/engagement_time.rb
Constant Summary collapse
- NEWSFEED =
Types of Engagement
0
Constants included from MongoMapper::Document
MongoMapper::Document::DUMP_ATTRS
Class Method Summary collapse
Methods included from MongoMapper::Document
#marshal_dump, #marshal_load, redis, update_cache_config
Class Method Details
.fakedata(args) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/octocore-mongo/models/enterprise/engagement_time.rb', line 20 def self.fakedata(args) res = self.where(args) enterprise = Octo::Enterprise.find_by_id(args[:enterprise_id]) if res.count == 0 and enterprise.fakedata? res = [] ts = args.fetch(ts, 7.days.ago..Time.now.floor) if ts.class == Range start_time = ts.begin.beginning_of_day end_time = ts.end.end_of_day start_time.to(end_time, 1.day).each do |_ts| _args = args.merge({ ts: _ts, time: (rand(5.0..7.0)*60).to_i }) res << self.new(_args).save! end elsif ts.class == Time _args = args.merge({ time: (rand(5.0..7.0)).to_i }) res << self.new(args).save! end end res end |