Created
August 17, 2011 17:18
-
-
Save simenbrekken/1152060 to your computer and use it in GitHub Desktop.
This file contains 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
var map = function() { | |
var completions = this.statistics.completions.total; | |
emit(key, { | |
created: { | |
count: 1, | |
length: this.length | |
}, | |
completed: { | |
count: completions, | |
length: this.length * completions | |
} | |
}); | |
}; | |
var reduce = function(key, values) { | |
var result = { | |
created: { | |
count: 0, | |
length: 0 | |
}, | |
completed: { | |
count: 0, | |
length: 0 | |
} | |
}; | |
for (var i = 0, l = values.length; i < l; ++i) { | |
var value = values[i]; | |
result.created.count += value.created.count; | |
result.created.length += value.created.length; | |
result.completed.count += value.completed.count; | |
result.completed.length += value.completed.length; | |
} | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment