Class: Totalizer::ChurnMessage

Inherits:
Message
  • Object
show all
Defined in:
lib/totalizer/message.rb

Instance Attribute Summary

Attributes inherited from Message

#description, #duration, #text

Instance Method Summary collapse

Methods inherited from Message

#percentage_string, #period_string

Constructor Details

#initialize(growth_metric, previous_activity_metric, this_activity_metc, duration) ⇒ ChurnMessage

Returns a new instance of ChurnMessage.



66
67
68
69
70
71
72
73
74
# File 'lib/totalizer/message.rb', line 66

def initialize growth_metric, previous_activity_metric, this_activity_metc, duration
  self.duration = duration

  new_and_existing = previous_activity_metric.value + growth_metric.value
  lost_existing = (previous_activity_metric.ids - this_activity_metc.ids).size
  final = new_and_existing - lost_existing
  self.text = "#{period_string}: #{percentage_string lost_existing.to_f / new_and_existing.to_f} (#{lost_existing}/#{new_and_existing})"
  self.description = "Did key activity last period but not this period over the total who did key activity last period plus new users"
end