Sha256: 114038ef3456afe6215c55dbe78e31a3bc36c71c8023693145d6b8844627a084
Contents?: true
Size: 1.36 KB
Versions: 13
Compression:
Stored size: 1.36 KB
Contents
class Conductor class RollUp def self.process Conductor::Experiment::Raw.since(14.days.ago).group_by(&:created_date).each do |day, daily_rows| # remove all the existing data for that day Conductor::Experiment::Daily.delete_all(:activity_date => day) daily_rows.group_by(&:group_name).each do |group_name, group_rows| group_rows.group_by(&:alternative).each do |alternative_name, alternatives| conversion_value = alternatives.select {|x| !x.conversion_value.nil?}.inject(0) {|res, x| res += x.conversion_value} views = alternatives.count conversions = alternatives.count {|x| !x.conversion_value.nil?} Conductor::Experiment::Daily.create!(:activity_date => day, :group_name => group_name, :alternative => alternative_name, :conversion_value => conversion_value, :views => views, :conversions => conversions ) end # delete the cache for this group so it can be recreated with the new values Conductor.cache.delete("Conductor::Experiment::#{group_name}::Alternatives") end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems