Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- db.statistics.aggregate([
- { $match: {
- $and: [
- { startingTime : {"$gte": new Date("2017-01-01T00:00:00.000Z") }},
- { master: { $regex: /rhos-qe-jenkins.*/ }},
- { projectName: {$regex: 'DFG.*-rhos'}},
- { result: 'SUCCESS'}
- ]
- }
- },
- { "$project": {
- "duration": "$duration",
- "month": { "$substr": [ "$startingTime", 0, 7 ] }
- }},
- { "$group": {
- "_id": "$month",
- "hours_avg": { "$avg": {$divide: ["$duration", 3600]} },
- "count": { "$sum": 1 }
- }},
- { "$sort": {"_id": 1} }
- ])
- /* 1 */
- {
- "_id" : "2017-01",
- "hours_avg" : 0.0,
- "count" : 3.0
- }
- /* 2 */
- {
- "_id" : "2017-02",
- "hours_avg" : 8.66822486772487,
- "count" : 105.0
- }
- /* 3 */
- {
- "_id" : "2017-05",
- "hours_avg" : 0.0,
- "count" : 23.0
- }
- /* 4 */
- {
- "_id" : "2017-06",
- "hours_avg" : 18.3405488051843,
- "count" : 823.0
- }
- /* 5 */
- {
- "_id" : "2017-07",
- "hours_avg" : 19.7344725343321,
- "count" : 89.0
- }
Advertisement
Add Comment
Please, Sign In to add comment