Skip to content

Commit

Permalink
Fixed scope type, added affiliates in fake logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Doug Youch committed Sep 17, 2010
1 parent 995edf7 commit ec3a8dd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/models/domain_log_session.rb
Expand Up @@ -44,7 +44,6 @@ def self.session(visitor_id,session_id,user,ip_address,save_entry=true,tracking=
referrer_id = nil
end


ses.attributes = {
:domain_log_visitor_id => visitor_id,
:affiliate => tracking.affiliate,
Expand Down Expand Up @@ -130,13 +129,13 @@ def self.affiliate(from, duration, intervals, opts={})
type = 'affiliate_traffic'
group = 'affiliate'
if opts[:affiliate] && opts[:campaign]
type = 'affiliate_campaign_origin_traffic'
type = "a:#{opts[:affiliate]}:c:#{opts[:campaign]}:traffic"
group = 'origin'
elsif opts[:affiliate]
type = 'affiliate_campaign_traffic'
type = "a:#{opts[:affiliate]}:traffic"
group = 'campaign'
elsif opts[:campaign]
type = 'campaign_affiliate_traffic'
type = "c:#{opts[:campaign]}:traffic"
group = 'affiliate'
end

Expand Down
17 changes: 17 additions & 0 deletions script/fake_log_entries.rb
Expand Up @@ -165,6 +165,7 @@ def build_options!(options)
end

add_referer! options
add_tracking! options
end

def add_referer!(options)
Expand All @@ -187,6 +188,22 @@ def add_referer!(options)
end
end

def add_tracking!(options)
return if @add_tracking
@add_tracking = true
@affiliates ||= ['google', 'yahoo', 'msn']
@campaigns ||= ['cms', 'trial', 'subscription']
@origins ||= {'google' => ['cmsworld.com', 'feedburner.com']}

if rand(100) < 30
affid = @affiliates[rand(@affiliates.size)]
c = @campaigns[rand(@campaigns.size)]
o = @origins[affid] ? @origins[affid][rand(@origins[affid].size)] : ''
f = 1 + rand(100000)
options[:query] = "affid=#{affid}&c=#{c}&o=#{o}&f=#{f}"
end
end

def add_product(product)
self.send product
self.send "add_#{product}", 'quantity' => 1+rand(3), 'action' => 'add_to_cart', 'product' => 1
Expand Down

0 comments on commit ec3a8dd

Please sign in to comment.