Move parseOffset function to a class method
This commit is contained in:
parent
9e3e1cad9a
commit
c37ef36a61
@ -495,14 +495,14 @@ module.exports = class Histogram extends BaseWidget {
|
||||
_aggregation: _aggregation,
|
||||
_start: this.getBinStart(override),
|
||||
_end: this.getBinEnd(override),
|
||||
_offset: parseOffset(_offset, _aggregation)
|
||||
_offset: this.parseOffset(_offset, _aggregation)
|
||||
});
|
||||
} else {
|
||||
dateBasicsQuery = dateBasicsQueryTpl({
|
||||
_query: _query,
|
||||
_column: _column,
|
||||
_aggregation: _aggregation,
|
||||
_offset: parseOffset(_offset, _aggregation)
|
||||
_offset: this.parseOffset(_offset, _aggregation)
|
||||
});
|
||||
}
|
||||
|
||||
@ -521,7 +521,7 @@ module.exports = class Histogram extends BaseWidget {
|
||||
_query: _query,
|
||||
_column: _column,
|
||||
_aggregation: _aggregation,
|
||||
_offset: parseOffset(_offset, _aggregation)
|
||||
_offset: this.parseOffset(_offset, _aggregation)
|
||||
});
|
||||
|
||||
var histogramSql = [
|
||||
@ -708,6 +708,18 @@ module.exports = class Histogram extends BaseWidget {
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
parseOffset (offset, aggregation) {
|
||||
if (!offset) {
|
||||
return '0';
|
||||
}
|
||||
if (aggregation === 'hour' || aggregation === 'minute') {
|
||||
return '0';
|
||||
}
|
||||
|
||||
var offsetInHours = Math.ceil(offset / 3600);
|
||||
return '' + offsetInHours;
|
||||
}
|
||||
};
|
||||
|
||||
var DATE_AGGREGATIONS = {
|
||||
@ -720,17 +732,3 @@ var DATE_AGGREGATIONS = {
|
||||
'quarter': true,
|
||||
'year': true
|
||||
};
|
||||
|
||||
|
||||
function parseOffset(offset, aggregation) {
|
||||
if (!offset) {
|
||||
return '0';
|
||||
}
|
||||
if (aggregation === 'hour' || aggregation === 'minute') {
|
||||
return '0';
|
||||
}
|
||||
|
||||
var offsetInHours = Math.ceil(offset / 3600);
|
||||
return '' + offsetInHours;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user