Class: Extractors::Total

Inherits:
Base
  • Object
show all
Defined in:
lib/prosperity/extractors/total.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.keyObject



3
4
5
# File 'lib/prosperity/extractors/total.rb', line 3

def self.key
  "total"
end

Instance Method Details

#to_aObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/prosperity/extractors/total.rb', line 7

def to_a
  data = []

  period.each_period(start_time, end_time) do |start_time|
    if metric.sql?
      data << count_up_to_date_with_sql(start_time)
    elsif metric.ruby?
      data << metric.value_at.call(start_time, period)
    else
      s = scope.where("#{metric.group_by} < ?", start_time)
      data << metric.aggregate.apply(s)
    end
  end

  data
end