Support automattic aggregation only when aggregation para is set to 'auto'
This commit is contained in:
parent
b2b68ffd5c
commit
9034508244
@ -21,6 +21,7 @@ function DataviewBackend(analysisBackend) {
|
||||
}
|
||||
|
||||
var DATE_AGGREGATIONS = {
|
||||
'auto': true,
|
||||
'minute': true,
|
||||
'hour': true,
|
||||
'day': true,
|
||||
|
@ -5,6 +5,8 @@ var debug = require('debug')('windshaft:dataview:histogram');
|
||||
var dot = require('dot');
|
||||
dot.templateSettings.strip = false;
|
||||
|
||||
var columnCastTpl = dot.template("date_part('epoch', {{=it.column}})");
|
||||
|
||||
var dateIntervalQueryTpl = dot.template([
|
||||
'WITH',
|
||||
'dates AS (',
|
||||
@ -331,10 +333,14 @@ Histogram.prototype._buildQuery = function (psql, override, callback) {
|
||||
var _column = this.column;
|
||||
var _query = this.query;
|
||||
|
||||
if (this._columnType === 'date') {
|
||||
if (this._columnType === 'date' && this.aggregation !== undefined) {
|
||||
return this._buildDateHistogramQuery(psql, override, callback);
|
||||
}
|
||||
|
||||
if (this._columnType === 'date') {
|
||||
_column = columnCastTpl({column: _column});
|
||||
}
|
||||
|
||||
filteredQuery = filteredQueryTpl({
|
||||
_isFloatColumn: this._columnType === 'float',
|
||||
_query: _query,
|
||||
@ -434,7 +440,7 @@ Histogram.prototype._buildDateHistogramQuery = function (psql, override, callbac
|
||||
var _aggregation = override && override.aggregation ? override.aggregation : this.aggregation;
|
||||
var _offset = override && Number.isFinite(override.offset) ? override.offset : this.offset;
|
||||
|
||||
if (!_aggregation) {
|
||||
if (_aggregation === 'auto') {
|
||||
this.getAutomaticAggregation(psql, function (err, aggregation) {
|
||||
if (err || aggregation === 'none') {
|
||||
this.aggregation = 'day';
|
||||
|
@ -160,7 +160,8 @@ describe('histogram-dataview for date column type', function() {
|
||||
},
|
||||
type: 'histogram',
|
||||
options: {
|
||||
column: 'd'
|
||||
column: 'd',
|
||||
aggregation: 'auto'
|
||||
}
|
||||
},
|
||||
date_histogram: {
|
||||
@ -179,7 +180,8 @@ describe('histogram-dataview for date column type', function() {
|
||||
},
|
||||
type: 'histogram',
|
||||
options: {
|
||||
column: 'd'
|
||||
column: 'd',
|
||||
aggregation: 'auto'
|
||||
}
|
||||
},
|
||||
minute_histogram: {
|
||||
|
Loading…
Reference in New Issue
Block a user