class Octo::Conversions

The conversions store

Constants

EMAIL
NEWSFEED

Types of conversions

PUSH_NOTIFICATION

Public Class Methods

data( enterprise_id, type, ts = 3.days.ago..Time.now.floor) click to toggle source
# File lib/octocore-cassandra/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() click to toggle source

Fetches the types of conversions possible @return [Hash] The conversion name and its value hash

# File lib/octocore-cassandra/models/enterprise/conversions.rb, line 28
      def types
        {
          'Newsfeed' => Octo::Conversions::NEWSFEED,
          'Notification' => Octo::Conversions::PUSH_NOTIFICATION,
#          'Email' => Octo::Conversions::EMAIL
        }
      end