Class: Abingo::Alternative

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ConversionRate
Defined in:
lib/abingo/alternative.rb

Class Method Summary collapse

Methods included from ConversionRate

#conversion_rate, #pretty_conversion_rate

Class Method Details

.calculate_lookup(test_name, alternative_name) ⇒ Object



10
11
12
# File 'lib/abingo/alternative.rb', line 10

def self.calculate_lookup(test_name, alternative_name)
  Digest::MD5.hexdigest(Abingo.salt + test_name + alternative_name.to_s)
end

.score_conversion(test_name, viewed_alternative) ⇒ Object



14
15
16
# File 'lib/abingo/alternative.rb', line 14

def self.score_conversion(test_name, viewed_alternative)
  self.update_all("conversions = conversions + 1", :lookup => self.calculate_lookup(test_name, viewed_alternative))
end

.score_participation(test_name, viewed_alternative) ⇒ Object



18
19
20
# File 'lib/abingo/alternative.rb', line 18

def self.score_participation(test_name, viewed_alternative)
  self.update_all("participants = participants + 1", :lookup => self.calculate_lookup(test_name, viewed_alternative))
end