|
|
@ -44,6 +44,92 @@ exports.round = function (number, precision) { |
|
|
|
return roundedTempNumber / factor; |
|
|
|
return roundedTempNumber / factor; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.numberRound = (number, precision) => { |
|
|
|
|
|
|
|
var factor = Math.pow(10, precision); |
|
|
|
|
|
|
|
var tempNumber = number * factor; |
|
|
|
|
|
|
|
var roundedTempNumber = Math.round(tempNumber); |
|
|
|
|
|
|
|
return roundedTempNumber / factor; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.numberGetLength = (number) => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var n = number; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (number < 0) { |
|
|
|
|
|
|
|
n = n * -1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return n.toString().length; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.numberGetFixed = (number) => { |
|
|
|
|
|
|
|
//console.log(number, typeof number);
|
|
|
|
|
|
|
|
return parseInt(number.toFixed()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.getRangeSimple = function (min, max, step) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var arr = [] |
|
|
|
|
|
|
|
for (var i = min; i <= max; i = i + step) { |
|
|
|
|
|
|
|
arr.push(i) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return arr; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.getRange = (min, max, stddev) => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log(' = = = = = = = ');
|
|
|
|
|
|
|
|
//console.log('original numbers', min, max, stddev);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min = this.numberGetFixed(min) |
|
|
|
|
|
|
|
max = this.numberGetFixed(max) |
|
|
|
|
|
|
|
stddev = this.numberGetFixed(stddev) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log('fixed numbers', min, max, stddev);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let minMinusHalf = min - stddev / 2 |
|
|
|
|
|
|
|
let maxMinusHalf = max + stddev / 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
minMinusHalf = this.numberGetFixed(minMinusHalf) |
|
|
|
|
|
|
|
maxMinusHalf = this.numberGetFixed(maxMinusHalf) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log('fixed numbers + (min,max)', min, max, stddev, '(', minMinusHalf, ',', maxMinusHalf, ')');
|
|
|
|
|
|
|
|
// console.log('numbers length', 'min', numberGetLength(min), 'max', numberGetLength(max), 'stddev', numberGetLength(stddev));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let minLen = this.numberGetLength(minMinusHalf) |
|
|
|
|
|
|
|
let maxLen = this.numberGetLength(maxMinusHalf) |
|
|
|
|
|
|
|
let stddevLen = this.numberGetLength(stddev) |
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// console.log('- - - -');
|
|
|
|
|
|
|
|
// console.log('Range', 'min', numberRound(minMinusHalf, -1));
|
|
|
|
|
|
|
|
// console.log('Range', 'max', numberRound(maxMinusHalf, -1));
|
|
|
|
|
|
|
|
// console.log('Range', 'stddev', numberRound(stddev, -1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (minLen > 1) |
|
|
|
|
|
|
|
minMinusHalf = this.numberRound(minMinusHalf, -1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (maxLen > 2) |
|
|
|
|
|
|
|
maxMinusHalf = this.numberRound(maxMinusHalf, -1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (stddevLen !== 1) |
|
|
|
|
|
|
|
stddev = this.numberRound(stddev, -1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var arr = [] |
|
|
|
|
|
|
|
for (var step = minMinusHalf; step < maxMinusHalf; step = step + stddev) { |
|
|
|
|
|
|
|
arr.push(step) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
arr.push(maxMinusHalf) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log(arr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return arr; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.getSchemaQuery = function () { |
|
|
|
exports.getSchemaQuery = function () { |
|
|
|
return 'select c.table_name, c.column_name, c.ordinal_position,c.column_key,c.is_nullable, c.data_type, c.column_type,c.extra,c.privileges, ' + |
|
|
|
return 'select c.table_name, c.column_name, c.ordinal_position,c.column_key,c.is_nullable, c.data_type, c.column_type,c.extra,c.privileges, ' + |
|
|
|
'c.column_comment,c.column_default,c.data_type,c.character_maximum_length, ' + |
|
|
|
'c.column_comment,c.column_default,c.data_type,c.character_maximum_length, ' + |
|
|
@ -68,3 +154,8 @@ exports.getSchemaQuery = function () { |
|
|
|
'order by ' + |
|
|
|
'order by ' + |
|
|
|
'c.table_name, c.ordinal_position'; |
|
|
|
'c.table_name, c.ordinal_position'; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.getChartQuery = function () { |
|
|
|
|
|
|
|
return 'select ? as ??, count(*) as _count from ?? where ?? between ? and ? ' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|