Skip to content

Instantly share code, notes, and snippets.

@bayleedev
Created May 14, 2014 21:04
Show Gist options
  • Save bayleedev/602308cf0afadd930403 to your computer and use it in GitHub Desktop.
Save bayleedev/602308cf0afadd930403 to your computer and use it in GitHub Desktop.
total = count = max = 0;
min = 999;
lastWeek = new Date('2014-05-07');
db.git_queue.find({status: {$ne: 'error'}, notified_build: {$ne: null}, finished_build: {$ne: null}}).forEach(function(el) {
if (new Date(el.notified_build) > lastWeek) {
total_ms = new Date(el.finished_build) - new Date(el.notified_build);
total_secs = total_ms / 1000;
total_mins = total_secs / 60;
count++;
total += total_mins;
max = Math.max(max, total_mins);
min = Math.min(min, total_mins);
}
});
print("AVG: " + total / count + "\nMAX: " + max + "\nMIN: " + min);
@bayleedev
Copy link
Author

Here are the results for the last week:

> db.git_queue.find({status: {$ne: 'error'}, notified_build: {$ne: null}, finished_build: {$ne: null}}).forEach(function(el) {
... if (new Date(el.notified_build) > lastWeek) {
... total_ms = new Date(el.finished_build) - new Date(el.notified_build);
... total_secs = total_ms / 1000;
... total_mins = total_secs / 60;
... count++;
... total += total_mins;
... max = Math.max(max, total_mins);
... min = Math.min(min, total_mins);
... }
... });
> print("AVG: " + total / count + "\nMAX: " + max + "\nMIN: " + min);
AVG: 2.7350282485875708
MAX: 8.166666666666666
MIN: 0.8166666666666667

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment