mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
21 lines
427 B
JavaScript
21 lines
427 B
JavaScript
// Print out event totals
|
|
|
|
// Usage:
|
|
// mongo <address>:<port>/<database> <script file> -u <username> -p <password>
|
|
|
|
var cursor = db['analytics.log.events'].aggregate(
|
|
[
|
|
{ $match : {}},
|
|
{
|
|
$group : {
|
|
_id: "$event",
|
|
total: {$sum: 1}
|
|
}
|
|
},
|
|
{ $sort : { total : -1} }
|
|
]);
|
|
|
|
while (cursor.hasNext()) {
|
|
var myDoc = cursor.next();
|
|
print(myDoc.total + "\t" + myDoc._id)
|
|
}
|