Extract method to check valid aggregation
This commit is contained in:
@@ -187,7 +187,7 @@ module.exports = class DateHistogram extends BaseHistogram {
|
||||
}
|
||||
|
||||
_buildQuery (psql, override, callback) {
|
||||
if (!DATE_AGGREGATIONS.hasOwnProperty(this._getAggregation(override))) {
|
||||
if (!this.isValidAggregation(override)) {
|
||||
return callback(new Error('Invalid aggregation value. Valid ones: ' +
|
||||
Object.keys(DATE_AGGREGATIONS).join(', ')
|
||||
));
|
||||
@@ -221,6 +221,10 @@ module.exports = class DateHistogram extends BaseHistogram {
|
||||
return callback(null, histogramSql);
|
||||
}
|
||||
|
||||
_isValidAggregation (override) {
|
||||
return DATE_AGGREGATIONS.hasOwnProperty(this._getAggregation(override));
|
||||
}
|
||||
|
||||
_getAutomaticAggregation (psql, callback) {
|
||||
const dateIntervalQuery = dateIntervalQueryTpl({
|
||||
query: this.query,
|
||||
|
||||
Reference in New Issue
Block a user