File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ use('xforge')
2+
3+ const metrics = db.event_metrics.aggregate([
4+ {
5+ $match: {
6+ eventType: 'StartBuildAsync'
7+ }
8+ },
9+ {
10+ $group: {
11+ _id: '$projectId',
12+ count: { $sum: 1 },
13+ timeStamps: { $push: '$timeStamp' }
14+ }
15+ },
16+ {
17+ $lookup: {
18+ from: 'sf_projects',
19+ localField: '_id',
20+ foreignField: '_id',
21+ as: 'project'
22+ }
23+ },
24+ { $unwind: '$project' },
25+ {
26+ $project: {
27+ _id: 1,
28+ count: 1,
29+ name: '$project.name',
30+ shortName: '$project.shortName',
31+ // only show the most recent timeStamp
32+ latestTimeStamp: { $arrayElemAt: [{ $slice: ['$timeStamps', -1] }, 0] }
33+ }
34+ },
35+ { $sort: { latestTimeStamp: -1 } },
36+ ]).toArray()
37+
38+ print('Project ID\tProject Name\tShort Name\tCount\tLatest TimeStamp')
39+ for (const metric of metrics) {
40+ print(`${metric._id}\t${metric.name}\t${metric.shortName}\t${metric.count}\t${metric.latestTimeStamp.toISOString().slice(0, -1)}`)
41+ }
You can’t perform that action at this time.
0 commit comments