Skip to content

Instantly share code, notes, and snippets.

@bowd
Created October 26, 2010 17:54
Show Gist options
  • Save bowd/647418 to your computer and use it in GitHub Desktop.
Save bowd/647418 to your computer and use it in GitHub Desktop.
if exists?(referrer = event[:referrer])
if ((matches = referrer.match(/([^\#]+)\#(.+)?\:(.+)?/))) && matches.size == 4
detail = "#{DETAILS}.#{escape(matches[2])}.#{escape(matches[3])}.#{PLAYS}"
# Here we split the stuff in the specialised referrer
# i.e. facebook.com#p:AwsomePage
# And we increment the detail below, but in the REFERRER for the update
# referrer is passed instead of matches[1] ( which is just the facebook.com )
buckets.each do |bucket|
@referrers_per_track.update({ TRACK => track_id, BUCKET => bucket, REFERRER => referrer }, {
'$inc' => {
PLAYS => 1,
detail => 1
}}, :upsert => true)
@referrers_per_user.update({ USER => owner_id, BUCKET => bucket, REFERRER => ref referrer }, {
'$inc' => {
PLAYS => 1,
detail => 1
}}, :upsert => true)
end
else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment