Created
November 11, 2010 14:12
-
-
Save bowd/672538 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def write(type, attributes, plan) | |
geo = resolve_geo(attributes[:remote_addr]) | |
listener = | |
if attributes[:anonymous] == true | |
-1 | |
else | |
( attributes[:user_id].to_i == 0 ? nil : attributes[:user_id].to_i ) | |
end | |
event = { | |
:type => type, | |
:id => attributes[:id].to_i, | |
:created_at => DateTime.parse(attributes[:created_at].to_s), | |
:track => attributes[:track_id].to_i, | |
:listener => listener, | |
:owner => attributes[:owner_id].to_i, | |
:country => geo[:country_code], | |
:region => geo[:region], | |
:app => attributes[:app], | |
:referrer => attributes[:referrer], | |
}.reject { |k,v| v.nil? } | |
Stats::MongoStore.store(plan).write(event) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment