Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- promisifiedAggregation(global.chooseDb(`metric`).collection(`releasesProd`), [
- {
- $project: {
- date: 1,
- _id: 0,
- number: 1,
- startDate: {$subtract: [`$date`, 1000 * 60 * 60 * 24 * 14]},
- },
- },
- {$sort: {number: 1}},
- ])
- .map(release =>
- Promise.all(
- promisifiedAggregation(
- global.chooseDb(`jmeter`).collection(`build_params`),
- [
- {
- $match: {
- executionDateUTC: {$gt: release.startDate, $lte: release.date},
- },
- },
- {$project: {id: 1, source: 1}},
- {$group: {id: `$source`, builds: {$push: `$_id`}}},
- ]
- ).map(build =>
- promisifiedAggregation(
- global.chooseDb(`jmeter`).collection(build.source),
- [
- {$match: {title: {$in: build.builds}}},
- {$project: {'all.count': 1, 'ko.count': 1, 'ok.count': 1}},
- {
- $group: {
- _id: build.source,
- success: {$sum: `$ok.count`},
- failure: {$sum: `$ko.count`},
- all: {$sum: `$all.count`},
- },
- },
- ]
- )
- )
- ).then(builds => ({releaseId: release.id, builds}))
- )
- .reduce((aggregation, {releaseId, builds}) =>
- Object.assign(aggregation, {[releaseId]: builds})
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement