Class: Wonkavision::Analytics::ApplyAggregation
- Inherits:
-
Object
- Object
- Wonkavision::Analytics::ApplyAggregation
- Includes:
- EventHandler
- Defined in:
- lib/wonkavision/plugins/analytics/handlers/apply_aggregation.rb
Instance Method Summary collapse
Methods included from EventHandler
Instance Method Details
#aggregation_for(aggregation_name) ⇒ Object
29 30 31 |
# File 'lib/wonkavision/plugins/analytics/handlers/apply_aggregation.rb', line 29 def aggregation_for(aggregation_name) Wonkavision::Aggregation.all[aggregation_name] end |
#process_event(event) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/wonkavision/plugins/analytics/handlers/apply_aggregation.rb', line 12 def process_event(event) return false unless (aggregation = aggregation_for(event["aggregation"])) && (action = event["action"]) && (measures = event["measures"]) && (dimensions = event["dimensions"]) raise "The only valid values for 'action' on an aggregation.updated message are 'add' and 'reject', #{action} was encountered. Message: #{event.inspect}" unless ["add", "reject"].include?(action.to_s) #Don't bother to continue if the measures are all nil if measures.values.detect{|m|m} action.to_s == "add" ? aggregation[dimensions].add(measures) : aggregation[dimensions].reject(measures) end end |