Class: Abingo::Alternative
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Abingo::Alternative
show all
- Includes:
- ConversionRate
- Defined in:
- lib/abingo/alternative.rb
Class Method Summary
collapse
#conversion_rate, #pretty_conversion_rate
Class Method Details
.calculate_lookup(test_name, alternative_name) ⇒ Object
7
8
9
|
# File 'lib/abingo/alternative.rb', line 7
def self.calculate_lookup(test_name, alternative_name)
Digest::MD5.hexdigest(Abingo.salt + test_name + alternative_name.to_s)
end
|
.score_conversion(test_name) ⇒ Object
11
12
13
14
15
|
# File 'lib/abingo/alternative.rb', line 11
def self.score_conversion(test_name)
viewed_alternative = Abingo.find_alternative_for_user(test_name,
Abingo::Experiment.alternatives_for_test(test_name))
self.update_all("conversions = conversions + 1", :lookup => self.calculate_lookup(test_name, viewed_alternative))
end
|
.score_participation(test_name) ⇒ Object
17
18
19
20
21
|
# File 'lib/abingo/alternative.rb', line 17
def self.score_participation(test_name)
viewed_alternative = Abingo.find_alternative_for_user(test_name,
Abingo::Experiment.alternatives_for_test(test_name))
self.update_all("participants = participants + 1", :lookup => self.calculate_lookup(test_name, viewed_alternative))
end
|