Sha256: 92aec3ae62d19f984ef53154d33c39b14fc8dbda6fec4ae554cbfbb646d757a2

Contents?: true

Size: 493 Bytes

Versions: 28

Compression:

Stored size: 493 Bytes

Contents

class MetricVariant < ActiveRecord::Base
  
  belongs_to :metric
  
  validates_presence_of :name
  validates_presence_of :metric_id
  
  def tally_serve(count = 1)
    MetricVariant.update_counters(self.id, :served => count)
    self.reload
  end
  
  def tally_convert(count = 1)
    MetricVariant.update_counters(self.id, :conversions => count)
    self.reload
  end
  
  def conversion_rate
    return nil if self.served == 0
    return self.conversions / self.served.to_f * 100
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
mountain-goat-0.0.9 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.0.8 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.0.6 lib/mountain_goat/models/metric_variant.rb
mountain-goat-0.0.5 lib/mountain_goat/models/metric_variant.rb
mountain-goat-0.0.4 lib/mountain_goat/models/metric_variant.rb
mountain-goat-0.0.3 lib/mountain_goat/models/metric_variant.rb
mountain-goat-0.0.2 lib/mountain_goat/models/metric_variant.rb
mountain-goat-0.0.1 lib/mountain_goat/models/metric_variant.rb