Skip to content

Instantly share code, notes, and snippets.

@speedmax
Created January 16, 2009 05:21
Show Gist options
  • Save speedmax/47826 to your computer and use it in GitHub Desktop.
Save speedmax/47826 to your computer and use it in GitHub Desktop.
// 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