Skip to content

Commit

Permalink
start/endTime para #23
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoefe committed Nov 8, 2016
1 parent dabf4c6 commit da79e08
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
22 changes: 13 additions & 9 deletions lib/txt-to-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,21 +631,25 @@ function prepare(info) {
}

function initializeStats(info) {
info.stats = {};
info.stats = {
startTime:new Date().getTime()
};
return info;
}

function finalizeStats(info) {
info.stats.rows = info.rows.length;
info.stats.columns = info.columnsInfo.length;
info.stats.textColumns = 0;
info.stats.nullColumns = 0;
info.stats.primaryKey = [];
var s = info.stats; // para no usar with
s.rows = info.rows.length;
s.columns = info.columnsInfo.length;
s.textColumns = 0;
s.nullColumns = 0;
s.primaryKey = [];
info.columnsInfo.forEach(function(column, index) {
if(column.typeInfo.isTextColumn) { ++info.stats.textColumns; }
if(column.hasNullValues) { ++info.stats.nullColumns; }
if(column.inPrimaryKey) { info.stats.primaryKey.push(column.name); }
if(column.typeInfo.isTextColumn) { ++s.textColumns; }
if(column.hasNullValues) { ++s.nullColumns; }
if(column.inPrimaryKey) { s.primaryKey.push(column.name); }
});
s.endTime = new Date().getTime();
return info;
}

Expand Down
10 changes: 9 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,15 @@ describe("fixtures", function(){
expect(differences(generated.rawSql,expected.rawSql)).to.eql(null);
// coherencia entre prepared y generated
expect(generated.errors).to.eql(prepared.errors);
if(expected.stats) { expect(generated.stats).to.eql(expected.stats); }
if(expected.stats) {
var stats = changing({},generated.stats);
delete stats.startTime;
delete stats.endTime;
expect(stats).to.eql(expected.stats);
expect(generated.stats.startTime).to.be.a('number');
expect(generated.stats.endTime).to.be.a('number');
//expect(generated.stats.endTime).to.be.greaterThan(generated.stats.startTime);
}
}).then(done,done);
});
}
Expand Down
22 changes: 13 additions & 9 deletions web/txt-to-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,21 +631,25 @@ function prepare(info) {
}

function initializeStats(info) {
info.stats = {};
info.stats = {
startTime:new Date().getTime()
};
return info;
}

function finalizeStats(info) {
info.stats.rows = info.rows.length;
info.stats.columns = info.columnsInfo.length;
info.stats.textColumns = 0;
info.stats.nullColumns = 0;
info.stats.primaryKey = [];
var s = info.stats; // para no usar with
s.rows = info.rows.length;
s.columns = info.columnsInfo.length;
s.textColumns = 0;
s.nullColumns = 0;
s.primaryKey = [];
info.columnsInfo.forEach(function(column, index) {
if(column.typeInfo.isTextColumn) { ++info.stats.textColumns; }
if(column.hasNullValues) { ++info.stats.nullColumns; }
if(column.inPrimaryKey) { info.stats.primaryKey.push(column.name); }
if(column.typeInfo.isTextColumn) { ++s.textColumns; }
if(column.hasNullValues) { ++s.nullColumns; }
if(column.inPrimaryKey) { s.primaryKey.push(column.name); }
});
s.endTime = new Date().getTime();
return info;
}

Expand Down

0 comments on commit da79e08

Please sign in to comment.