Module: Statisfy::Aggregate::ClassMethods
- Defined in:
- lib/statisfy/aggregate.rb
Instance Method Summary collapse
-
#aggregate(args = {}) ⇒ Object
Simply a shortcut for declaring an aggregation type counter.
-
#value(scope: nil, month: nil) ⇒ Object
Average type counters ret.
Instance Method Details
#aggregate(args = {}) ⇒ Object
Simply a shortcut for declaring an aggregation type counter
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
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 |