def aggregate!(ts = Time.now.floor)
      unless self.ancestors.include?Cequel::Record
        raise NoMethodError, 'aggregate! not defined for this counter'
      end

      aggr = aggregate(ts)
      sum = aggregate_sum(aggr)
      aggr.each do |_ts, counterVals|
        counterVals.each do |obj, count|
          counter = self.new
          counter.enterprise_id = obj.enterprise.id
          counter.uid = obj.unique_id
          counter.count = count
          counter.type = Octo::Counter::TYPE_MINUTE
          counter.ts = _ts
          totalCount = sum[_ts][obj.enterprise_id.to_s].to_f
          counter.obp = (count * 1.0)/totalCount

          baseline_value = get_baseline_value(:TYPE_MINUTE, obj)
          counter.divergence = kl_divergence(counter.obp,
                                             baseline_value)
          counter.save!
        end
      end
      call_completion_hook(Octo::Counter::TYPE_MINUTE, ts)
    end
def aggregate!(ts = Time.now.floor)
      unless self.ancestors.include?Cequel::Record
        raise NoMethodError, 'aggregate! not defined for this counter'
      end

      aggr = aggregate(ts)
      sum = aggregate_sum(aggr)
      aggr.each do |_ts, counterVals|
        counterVals.each do |obj, count|
          counter = self.new
          counter.enterprise_id = obj.enterprise.id
          counter.uid = obj.unique_id
          counter.count = count
          counter.type = Octo::Counter::TYPE_MINUTE
          counter.ts = _ts
          totalCount = sum[_ts][obj.enterprise_id.to_s].to_f
          counter.obp = (count * 1.0)/totalCount

          baseline_value = get_baseline_value(:TYPE_MINUTE, obj)
          counter.divergence = kl_divergence(counter.obp,
                                             baseline_value)
          counter.save!
        end
      end
      call_completion_hook(Octo::Counter::TYPE_MINUTE, ts)
    end
Aggregates and attempts to store it into the database. This would only
   work if the class that extends Octo::Counter includes from
   Cequel::Record