Class: Sleek::Queries::Sum

Inherits:
Query
  • Object
show all
Defined in:
lib/sleek/queries/sum.rb

Overview

Internal: Sum query.

Finds the average value for a given property.

target_property - the String name of target property on event.

Examples

sleek.queries.sum(:purchases, target_property: "total")
# => 2_072_70

Instance Attribute Summary

Attributes inherited from Query

#bucket, #namespace, #options, #timeframe

Instance Method Summary collapse

Methods inherited from Query

#apply_filters, #events, #filter?, #filters, #group_by, #initialize, require_target_property!, require_target_property?, #run, #target_property, #timeframe?, #valid_options?

Constructor Details

This class inherits a constructor from Sleek::Queries::Query

Instance Method Details

#perform(events) ⇒ Object



16
17
18
# File 'lib/sleek/queries/sum.rb', line 16

def perform(events)
  events.sum target_property
end