github.com/justinjmoses/evergreen@v0.0.0-20170530173719-1d50e381ff0d/scripts/report_scratch.js (about) 1 print("do not run this file"); 2 (function(){ 3 4 // spawnhosts per month 5 db.hosts.aggregate([{$match:{started_by:{"$ne": "mci"}}}, 6 {$group:{_id: {month: { $month: "$creation_time" }, year: { $year: "$creation_time" }}, total:{ $sum: 1 }}}, 7 {$sort: {"_id.year":1, "_id.month":1}}]) 8 9 // spawnhosts per month as CSV 10 db.hosts.aggregate([{$match:{started_by:{"$ne": "mci"}}}, 11 {$group:{_id: {month: { $month: "$creation_time" }, year: { $year: "$creation_time" }}, total:{ $sum: 1 }}}, 12 {$sort: {"_id.year":1, "_id.month":1}}]).result.forEach( 13 function(result){print(result._id.month+"/1/"+result._id.year+", "+result.total);}) 14 15 16 // hosts per month as CSV 17 db.hosts.aggregate([{$match:{started_by: "mci", creation_time:{$gt: new Date(Date().getTime() - 1000*60*60*600)}}}, 18 {$group:{_id: {month: { $month: "$creation_time" }, year: { $year: "$creation_time" }}, total:{ $sum: 1 }}}, 19 {$sort: {"_id.year":1, "_id.month":1}}]).result.forEach( 20 function(result){print(result._id.month+"/1/"+result._id.year+", "+result.total);}) 21 22 23 // patches per month, csv 24 db.versions.aggregate([{$match:{create_time:{$exists:true}, r:"patch_request"}}, 25 {$group:{_id: {month: { $month: "$create_time" }, year: { $year: "$create_time" }}, total:{ $sum: 1 }}}, 26 {$sort: {"_id.year":1, "_id.month":1}}]).result.forEach( 27 function(result){print(result._id.month+"/1/"+result._id.year+", "+result.total);}) 28 29 30 // git versions per month, csv 31 db.versions.aggregate([{$match:{create_time:{$exists:true}, r:"gitter_request"}}, 32 {$group:{_id: {month: { $month: "$create_time" }, year: { $year: "$create_time" }}, total:{ $sum: 1 }}}, 33 {$sort: {"_id.year":1, "_id.month":1}}]).result.forEach( 34 function(result){print(result._id.month+"/1/"+result._id.year+", "+result.total);}) 35 36 // patches per month per project, csv 37 db.versions.aggregate([{$match:{create_time:{$exists:true}, r:"patch_request", identifier:{$exists:true}}}, 38 {$group:{_id: {project:"$identifier", month: { $month: "$create_time" }, year: { $year: "$create_time" }}, total:{ $sum: 1 }}}, 39 {$sort: {"_id.project":1, "_id.year":1, "_id.month":1}}]).result.forEach( 40 function(result){print(result._id.project+", "+result._id.month+"/1/"+result._id.year+", "+result.total);}) 41 42 // git version per month per project, csv 43 db.versions.aggregate([{$match:{create_time:{$exists:true}, r:"gitter_request", identifier:{$exists:true}}}, 44 {$group:{_id: {project:"$identifier", month: { $month: "$create_time" }, year: { $year: "$create_time" }}, total:{ $sum: 1 }}}, 45 {$sort: {"_id.project":1, "_id.year":1, "_id.month":1}}]).result.forEach( 46 function(result){print(result._id.project+", "+result._id.month+"/1/"+result._id.year+", "+result.total);}) 47 48 49 // task hours per month, csv 50 db.tasks.aggregate([{$match:{ 51 status: {"$in": ["success", "failed"]}, 52 start_time:{$gt:new Date(new Date().getTime() - 1000*60*60*24*400)}, 53 finish_time:{$gt: new Date(new Date().getTime() - 1000*60*60*24*400)}}}, 54 {$group:{_id: {month: { $month: "$start_time" }, year: { $year: "$start_time" }}, total:{ 55 $sum: {$subtract: ["$finish_time", "$start_time"]}}}}, 56 {$sort: {"_id.year":1, "_id.month":1}}]).result.forEach( 57 function(result){print(result._id.month+"/1/"+result._id.year+", "+result.total/(60*60*1000));}); 58 59 60 // task hours per month by project, csv (THIS TAKES ABOUT AN HOUR TO RUN) 61 db.tasks.aggregate([{$match:{ 62 status: {"$in": ["success", "failed"]}, 63 start_time:{$gt:new Date(new Date().getTime() - 1000*60*60*24*400)}, 64 finish_time:{$gt: new Date(new Date().getTime() - 1000*60*60*24*400)}}}, 65 {$group:{_id: {month:{$month: "$start_time" }, year:{$year: "$start_time"}, project: "$branch"}, total:{ 66 $sum: {$subtract: ["$finish_time", "$start_time"]}}}}, 67 {$sort: {"_id.project":1, "_id.year":1, "_id.month":1}}]).result.forEach( 68 function(result){print(result._id.project+", "+result._id.month+"/1/"+result._id.year+", "+result.total/(60*60*1000));}); 69 70 71 // host hours per month, csv 72 db.hosts.aggregate([{$match:{ 73 creation_time:{$gt:new Date(new Date().getTime() - 1000*60*60*24*400)}, 74 termination_time: {$gt:new Date(new Date().getTime() - 1000*60*60*24*400)}}}, 75 {$group: { _id: {month: {$month: "$creation_time"}, year: {$year: "$creation_time"}}, total: {$sum:{$subtract:["$termination_time", "$creation_time"]}}}}, 76 {$sort: {"_id.year":1, "_id.month":1}}]).result.forEach( 77 function(result){print(result._id.month+"/1/"+result._id.year+", "+result.total/(60*60*1000));}); 78 79 80 // average task time and cost for a git and patch versions per project 81 db.tasks.aggregate([{$match:{ 82 status: {"$in": ["success", "failed"]}, 83 start_time:{$gt:new Date(new Date().getTime() - 1000*60*60*24*7)}, 84 finish_time:{$gt: new Date(new Date().getTime() - 1000*60*60*24*7)}, 85 cost:{$exists:true}}}, 86 {$group: {_id:{v: "$version", p: "$branch", r: "$r"}, cost: {$sum: "$cost"}, time: {$sum: {$subtract: ["$finish_time", "$start_time"]}}}}, 87 {$group: {_id: {p: "$_id.p", r: "$_id.r"}, cost: {$avg: "$cost"}, time: {$avg: "$time"}}}, 88 {$sort: {"_id.p":1, "_id.r":1}}, 89 ]).result.forEach( 90 function(result){print(result._id.p+", "+result._id.r+", $"+result.cost+", "+result.time/(60*60*1000));}); 91 92 93 94 })