Guest User

Untitled

a guest
Jul 5th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. db.statistics.aggregate([
  2.  
  3. { $match: {
  4. $and: [
  5. { startingTime : {"$gte": new Date("2017-01-01T00:00:00.000Z") }},
  6. { master: { $regex: /rhos-qe-jenkins.*/ }},
  7. { projectName: {$regex: 'DFG.*-rhos'}},
  8. { result: 'SUCCESS'}
  9. ]
  10. }
  11. },
  12.  
  13. { "$project": {
  14. "duration": "$duration",
  15. "month": { "$substr": [ "$startingTime", 0, 7 ] }
  16. }},
  17. { "$group": {
  18. "_id": "$month",
  19. "hours_avg": { "$avg": {$divide: ["$duration", 3600]} },
  20. "count": { "$sum": 1 }
  21. }},
  22. { "$sort": {"_id": 1} }
  23. ])
  24.  
  25. /* 1 */
  26. {
  27. "_id" : "2017-01",
  28. "hours_avg" : 0.0,
  29. "count" : 3.0
  30. }
  31.  
  32. /* 2 */
  33. {
  34. "_id" : "2017-02",
  35. "hours_avg" : 8.66822486772487,
  36. "count" : 105.0
  37. }
  38.  
  39. /* 3 */
  40. {
  41. "_id" : "2017-05",
  42. "hours_avg" : 0.0,
  43. "count" : 23.0
  44. }
  45.  
  46. /* 4 */
  47. {
  48. "_id" : "2017-06",
  49. "hours_avg" : 18.3405488051843,
  50. "count" : 823.0
  51. }
  52.  
  53. /* 5 */
  54. {
  55. "_id" : "2017-07",
  56. "hours_avg" : 19.7344725343321,
  57. "count" : 89.0
  58. }
Advertisement
Add Comment
Please, Sign In to add comment