Improve readability, using extract method pattern
This commit is contained in:
parent
42e2f9e4b1
commit
35d4fb4d27
@ -399,11 +399,7 @@ Histogram.prototype.format = function(result, override) {
|
||||
width = firstRow.bin_width || width;
|
||||
avg = firstRow.avg_val;
|
||||
nulls = firstRow.nulls_count;
|
||||
binsStart = override.hasOwnProperty('start') ?
|
||||
getBinStart(override) :
|
||||
firstRow.hasOwnProperty('timestamp') ?
|
||||
firstRow.timestamp :
|
||||
firstRow.min;
|
||||
binsStart = populateBinStart(override, firstRow);
|
||||
|
||||
buckets = result.rows.map(function(row) {
|
||||
return _.omit(row, 'bins_number', 'bin_width', 'nulls_count', 'avg_val');
|
||||
@ -457,6 +453,20 @@ function getTimezone(timezone) {
|
||||
return '' + timezoneInHours;
|
||||
}
|
||||
|
||||
function populateBinStart(override, firstRow) {
|
||||
var binStart;
|
||||
|
||||
if (override.hasOwnProperty('start')) {
|
||||
binStart = getBinStart(override);
|
||||
} else if (firstRow.hasOwnProperty('timestamp')) {
|
||||
binStart = firstRow.timestamp;
|
||||
} else {
|
||||
binStart = firstRow.min;
|
||||
}
|
||||
|
||||
return binStart;
|
||||
}
|
||||
|
||||
Histogram.prototype.getType = function() {
|
||||
return TYPE;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user