1 var horizon = new Date(Date.now() - 86400000 * 90);
2 function objectIdFromDate(date) {
3 return Math.floor(date.getTime() / 1000).toString(16) + '0000000000000000';
6 var firstId = ObjectId(objectIdFromDate(horizon));
8 var result = db.chatmessages.aggregate([
17 chatCount: { $sum: 1 }
36 if: { $eq: ['$troupe.githubType', 'ORG'] },
37 then: '$troupe.lcUri',
38 else: '$troupe.lcOwner'
47 chatCount: { $sum: '$chatCount' }
59 result.forEach(function(x) {
60 print(x._id + '\t' + x.chatCount);