Permalink
Browse files

Removing all evidence of CachedFind and variant lock

  • Loading branch information...
1 parent 36c6087 commit 71030975e85f8bfbeb6a82f26385563bf2d2b842 @winton committed Nov 9, 2010
Showing with 28 additions and 56 deletions.
  1. +0 −9 db/migrate/014_variants_lock.rb
  2. +0 −9 db/migrate/015_remove_variants_lock.rb
  3. +0 −2 lib/a_b/model/env.rb
  4. +28 −36 lib/a_b/model/variant.rb
@@ -1,9 +0,0 @@
-class VariantsLock < ActiveRecord::Migration
- def self.up
- add_column :variants, :lock_version, :integer, :default => 0
- end
-
- def self.down
- remove_column :variants, :lock_version
- end
-end
@@ -1,9 +0,0 @@
-class RemoveVariantsLock < ActiveRecord::Migration
- def self.up
- remove_column :variants, :lock_version
- end
-
- def self.down
- add_column :variants, :lock_version, :integer, :default => 0
- end
-end
View
@@ -1,7 +1,5 @@
class Env < ActiveRecord::Base
- extend CachedFind
-
belongs_to :site
belongs_to :user
View
@@ -1,7 +1,5 @@
class Variant < ActiveRecord::Base
- extend CachedFind
-
belongs_to :category
belongs_to :site
belongs_to :test, :class_name => 'ABTest', :foreign_key => 'test_id'
@@ -53,45 +51,39 @@ def self.record(options)
return [ [], [] ] if variants.empty? || !env
- begin
- visit = []
- convert = []
-
- variants.each do |variant|
- next unless env.domain_match?(options[:referer])
- variant.env = env.name
- visit.push(variant) if data['v'].include?(variant.id)
- convert.push(variant) if data['c'].include?(variant.id)
- end
-
- visit.each do |v|
- v.visits += 1
- if data['e'] && !data['e'].empty?
- v.visit_conditions ||= {}
- (data['e'] || {}).each do |key, value|
- v.visit_conditions[key] ||= 0
- v.visit_conditions[key] += 1 if value
- end
+ visit = []
+ convert = []
+
+ variants.each do |variant|
+ next unless env.domain_match?(options[:referer])
+ variant.env = env.name
+ visit.push(variant) if data['v'].include?(variant.id)
+ convert.push(variant) if data['c'].include?(variant.id)
+ end
+
+ visit.each do |v|
+ v.visits += 1
+ if data['e'] && !data['e'].empty?
+ v.visit_conditions ||= {}
+ (data['e'] || {}).each do |key, value|
+ v.visit_conditions[key] ||= 0
+ v.visit_conditions[key] += 1 if value
end
end
-
- convert.each do |c|
- c.conversions += 1
- if data['e'] && !data['e'].empty?
- c.conversion_conditions ||= {}
- (data['e'] || {}).each do |key, value|
- c.conversion_conditions[key] ||= 0
- c.conversion_conditions[key] += 1 if value
- end
+ end
+
+ convert.each do |c|
+ c.conversions += 1
+ if data['e'] && !data['e'].empty?
+ c.conversion_conditions ||= {}
+ (data['e'] || {}).each do |key, value|
+ c.conversion_conditions[key] ||= 0
+ c.conversion_conditions[key] += 1 if value
end
end
-
- variants.each(&:save)
-
- rescue ActiveRecord::StaleObjectError => e
- variants.each(&:reload)
- retry
end
+
+ variants.each(&:save)
[ visit.collect(&:id), convert.collect(&:id) ]
end

0 comments on commit 7103097

Please sign in to comment.