Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
Only count conversions for participants (or implicit conversions)
Browse files Browse the repository at this point in the history
This makes it so the "total conversion count" (as opposed to unique converted participant count) will only be tallied for participants (or implicit conversions), thus making it behave similarly to how unique participant conversions are tallied.
Coincidentally, also fixes active record conversion counting (previously it treated conversions as implicit even though the argument defaults to false).
  • Loading branch information
sdhull committed Nov 30, 2016
1 parent 0667603 commit 8e84e9a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions lib/vanity/adapters/active_record_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ def ab_add_conversion(experiment, alternative, identity, options={})
implicit = !!options[:implicit]
metric_id = options[:metric_id] # unsupported for ActiveRecord

VanityParticipant.retrieve(experiment, identity, false)
VanityParticipant.retrieve(experiment, identity, implicit, :converted => alternative)
VanityExperiment.retrieve(experiment).increment_conversion(alternative, count)
if VanityParticipant.retrieve(experiment, identity, implicit, :converted => alternative)
VanityExperiment.retrieve(experiment).increment_conversion(alternative, count)
end
end

# Returns the outcome of this experiment (if set), the index of a
Expand Down
14 changes: 7 additions & 7 deletions lib/vanity/adapters/mongodb_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,14 @@ def ab_add_conversion(experiment, alternative, identity, options={})
},
:upsert=>true
)
end

@experiments.find(:_id=>experiment).find_one_and_replace(
{
"$inc"=>{ "conversions.#{alternative}"=>count }
},
:upsert=>true
)
@experiments.find(:_id=>experiment).find_one_and_replace(
{
"$inc"=>{ "conversions.#{alternative}"=>count }
},
:upsert=>true
)
end
end

def ab_get_outcome(experiment)
Expand Down
3 changes: 1 addition & 2 deletions lib/vanity/adapters/redis_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,8 @@ def ab_add_conversion(experiment_id, alternative, identity, options={})

if implicit || participating
@experiments.sadd "#{experiment_id}:alts:#{alternative}:metric:#{metric_id}:converted", identity
@experiments.incrby "#{experiment_id}:alts:#{alternative}:metric:#{metric_id}:conversions", count
end

@experiments.incrby "#{experiment_id}:alts:#{alternative}:metric:#{metric_id}:conversions", count
end
end

Expand Down

0 comments on commit 8e84e9a

Please sign in to comment.