Created
January 16, 2009 05:21
-
-
Save speedmax/47826 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
// Map function | |
function(doc) { | |
// Format date to yyyy mm dd | |
var date = doc.created_at.replace(/T|-/g, ' ').replace('+', ' +'); | |
// return advertiser, date | |
emit(doc.accounts.advertiser, date.substring(0,10)) | |
} | |
// Reduce function | |
function(keys, values) { | |
var results = {}; | |
for (var i=0; i < values.length; i++) { | |
var current = values[i]; | |
if (!results[current]) { | |
results[current] = 0 ; | |
} | |
results[current]++; | |
} | |
return results; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment