Module: Statisfy::Aggregate::ClassMethods

Defined in:
lib/statisfy/aggregate.rb

Instance Method Summary collapse

Instance Method Details

#aggregate(args = {}) ⇒ Object

Simply a shortcut for declaring an aggregation type counter

Raises:

  • (ArgumentError)


16
17
18
19
20
# File 'lib/statisfy/aggregate.rb', line 16

def aggregate(args = {})
  raise ArgumentError, "You must provide the value to aggregate" if args[:value].blank?

  count(args.merge(type: :aggregate))
end

#value(scope: nil, month: nil) ⇒ Object

Average type counters ret

Parameters:

  • scope: (defaults to: nil)

    the scope of the counter (an Organisation or a Department)

  • month: (defaults to: nil)

    the month for which you want the value of the counter (optional)



28
29
30
31
# File 'lib/statisfy/aggregate.rb', line 28

def value(scope: nil, month: nil)
  month = month&.strftime("%Y-%m") if month.present?
  average(scope:, month:)
end