Move getOffset function to a class method

This commit is contained in:
Daniel García Aubert 2017-09-06 13:53:48 +02:00
parent 96740b82ed
commit 288656301b

View File

@ -607,7 +607,7 @@ module.exports = class Histogram extends BaseWidget {
if (Number.isFinite(timestampStart)) { if (Number.isFinite(timestampStart)) {
aggregation = this.getAggregation(override); aggregation = this.getAggregation(override);
offset = getOffset(override, this.offset); offset = this.getOffset(override);
} }
buckets = result.rows.map(function(row) { buckets = result.rows.map(function(row) {
@ -654,6 +654,17 @@ module.exports = class Histogram extends BaseWidget {
getAggregation (override) { getAggregation (override) {
return override && override.aggregation ? override.aggregation : this.aggregation; return override && override.aggregation ? override.aggregation : this.aggregation;
} }
getOffset (override) {
if (override && override.offset) {
return override.offset;
}
if (this.offset) {
return this.offset;
}
return 0;
}
}; };
var DATE_AGGREGATIONS = { var DATE_AGGREGATIONS = {
@ -667,18 +678,6 @@ var DATE_AGGREGATIONS = {
'year': true 'year': true
}; };
function getOffset(override, offset) {
if (override && override.offset) {
return override.offset;
}
if (offset) {
return offset;
}
return 0;
}
function getBinStart(override) { function getBinStart(override) {
if (override.hasOwnProperty('start') && override.hasOwnProperty('end')) { if (override.hasOwnProperty('start') && override.hasOwnProperty('end')) {
return Math.min(override.start, override.end); return Math.min(override.start, override.end);