Skip to content

Commit

Permalink
added time elapsed
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbeletsky committed May 1, 2014
1 parent 3afefea commit 62d76a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"underscore": "~1.6.0",
"request": "~2.34.0",
"single-line-log": "~0.3.1",
"elasticsearch": "~2.1.4"
"elasticsearch": "~2.1.4",
"moment": "~2.6.0"
}
}
12 changes: 11 additions & 1 deletion source/elaster.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var _ = require('underscore');
var moment = require('moment');
var async = require('async');
var config = require('../config');

Expand All @@ -10,6 +11,10 @@ var single = require('single-line-log');

require('colors');

function format(duration) {
return duration.hours() + ':' + duration.minutes() + ':' + duration.seconds() + ':' + duration.milliseconds();
}

function exportCollection(desc, callback) {
var collection = db[desc.name];

Expand All @@ -19,6 +24,8 @@ function exportCollection(desc, callback) {

console.log(('====> exporting collection [' + desc.name + ']').bold.white);

var started = moment();

async.waterfall([
function (next) {
console.log('----> checking connection to elastic');
Expand Down Expand Up @@ -118,7 +125,10 @@ function exportCollection(desc, callback) {
return callback(err);
}

console.log(('====> collection [' + desc.name + '] - exported successfully.\n').bold.green);
var duration = moment.duration(moment().diff(started));

console.log(('====> collection [' + desc.name + '] - exported successfully.').green);
console.log(('====> time elapsed ' + format(duration) + '\n').green);

callback(null);
});
Expand Down

0 comments on commit 62d76a4

Please sign in to comment.