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.1.8 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.1.7 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.1.6 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.1.5 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.1.4 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.1.3 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.1.2 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.1.1 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.1.0 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.0.20 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.0.19 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.0.18 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.0.17 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.0.16 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.0.15 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.0.14 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.0.13 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.0.12 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.0.11 lib/mountain-goat/models/metric_variant.rb
mountain-goat-0.0.10 lib/mountain-goat/models/metric_variant.rb