Class: Conductor::Experiment::Daily
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Conductor::Experiment::Daily
- Defined in:
- lib/conductor/experiment/daily.rb
Overview
Schema Information
Table name: conductor_daily_experiments
id :integer not null, primary key
activity_date :date
group_name :string(255)
option_name :string(255)
conversion_value :decimal(8, 2)
views :integer
conversions :integer
Class Method Summary collapse
- .find_equalization_period_stats_for(group_name, alternatives = nil) ⇒ Object
- .find_post_equalization_period_stats_for(group_name, alternatives = nil) ⇒ Object
Class Method Details
.find_equalization_period_stats_for(group_name, alternatives = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/conductor/experiment/daily.rb', line 20 def self.find_equalization_period_stats_for(group_name, alternatives=nil) alternative_filter = alternatives ? alternatives.inject([]) {|res,x| res << "alternative = '#{Conductor.sanitize(x)}'"}.join(' OR ') : 'true' sql = "SELECT alternative, min(activity_date) AS activity_date FROM conductor_daily_experiments WHERE group_name = '#{group_name}' AND (#{alternative_filter}) GROUP BY alternative HAVING min(activity_date) > '#{Date.today - Conductor.equalization_period}'" self.find_by_sql(sql) end |
.find_post_equalization_period_stats_for(group_name, alternatives = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/conductor/experiment/daily.rb', line 34 def self.find_post_equalization_period_stats_for(group_name, alternatives=nil) alternative_filter = alternatives ? alternatives.inject([]) {|res,x| res << "alternative = '#{Conductor.sanitize(x)}'"}.join(' OR ') : 'true' sql = "SELECT alternative, min(activity_date) AS activity_date, sum(views) AS views, sum(conversions) AS conversions, sum(conversion_value) AS conversion_value FROM conductor_daily_experiments WHERE group_name = '#{group_name}' AND (#{alternative_filter}) AND activity_date >= (SELECT max(min_date) FROM (SELECT alternative, min(activity_date) AS min_date FROM conductor_daily_experiments WHERE activity_date >= '#{Date.today - Conductor.inclusion_period}' GROUP BY alternative) AS a) GROUP BY alternative HAVING min(activity_date) <= '#{Date.today - Conductor.equalization_period}'" self.find_by_sql(sql) end |