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 = new ObjectId(objectIdFromDate(horizon));
8 var result = db.troupeusers.aggregate([
17 newUsers: { $addToSet: '$userId' }
35 if: { $eq: ['$troupe.githubType', 'ORG'] },
36 then: '$troupe.lcUri',
37 else: '$troupe.lcOwner'
44 $match: { _id: { $ne: null } }
52 newUsers: { $addToSet: '$newUsers' }
58 newUserCount: { $size: '$newUsers' }
71 print('Group\tCount');
73 result.forEach(function(x) {
74 print(x._id + '\t' + x.newUserCount);