Move check of default-aggregation to mapconfig model
This commit is contained in:
@@ -82,7 +82,8 @@ module.exports = class AggregationMapConfig extends MapConfig {
|
||||
threshold,
|
||||
placement,
|
||||
columns,
|
||||
dimensions
|
||||
dimensions,
|
||||
isDefaultAggregation: this._isDefaultLayerAggregation(index)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ const DEFAULT_PLACEMENT = 'point-sample';
|
||||
*/
|
||||
const templateForOptions = (options) => {
|
||||
let templateFn = defaultAggregationQueryTemplate;
|
||||
if (!isDefaultAggregation(options)) {
|
||||
if (!options.isDefaultAggregation) {
|
||||
templateFn = aggregationQueryTemplates[options.placement || DEFAULT_PLACEMENT];
|
||||
if (!templateFn) {
|
||||
throw new Error("Invalid Aggregation placement: '" + options.placement + "'");
|
||||
@@ -24,18 +24,6 @@ const templateForOptions = (options) => {
|
||||
return templateFn;
|
||||
};
|
||||
|
||||
const isEmptyParameter = (parameter) => !parameter || Object.keys(parameter).length === 0;
|
||||
|
||||
/**
|
||||
* When no placement, columns or dimensions are specified in the aggregation
|
||||
* a special default aggregation is used.
|
||||
*/
|
||||
const isDefaultAggregation = (options) => {
|
||||
return !options || (
|
||||
!options.placement && isEmptyParameter(options.columns) && isEmptyParameter(options.dimensions)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates an aggregation query given the aggregation options:
|
||||
* - query
|
||||
@@ -59,9 +47,6 @@ const queryForOptions = (options) => templateForOptions(options)({
|
||||
|
||||
module.exports = queryForOptions;
|
||||
|
||||
// Checks if the aggregation parameters represent the default (full-sample) aggregation
|
||||
module.exports.isDefaultAggregation = isDefaultAggregation;
|
||||
|
||||
const SUPPORTED_AGGREGATE_FUNCTIONS = {
|
||||
'count': {
|
||||
sql: (column_name, params) => `count(${params.aggregated_column || '*'})`
|
||||
|
||||
Reference in New Issue
Block a user