Extract method
This commit is contained in:
parent
d01857923e
commit
0887e5d5f7
@ -6,24 +6,7 @@ module.exports = class AggregationMapConfigAdapter {
|
||||
return callback(null, requestMapConfig);
|
||||
}
|
||||
|
||||
requestMapConfig.layers.forEach(layer => {
|
||||
if (!this._hasLayerAggregation(layer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const aggregation = new AggregationProxy(requestMapConfig, layer.options.aggregation);
|
||||
|
||||
let aggregationSql = aggregation.sql();
|
||||
|
||||
const sqlQueryWrap = layer.options.sql_wrap;
|
||||
|
||||
if (sqlQueryWrap) {
|
||||
layer.options.sql_raw = aggregationSql;
|
||||
aggregationSql = sqlQueryWrap.replace(/<%=\s*sql\s*%>/g, aggregationSql);
|
||||
}
|
||||
|
||||
layer.options.sql = aggregationSql;
|
||||
});
|
||||
requestMapConfig = this._adaptLayers(requestMapConfig);
|
||||
|
||||
callback(null, requestMapConfig);
|
||||
}
|
||||
@ -60,4 +43,25 @@ module.exports = class AggregationMapConfigAdapter {
|
||||
const { aggregation } = layer.options;
|
||||
return aggregation !== undefined && (typeof aggregation === 'object' && typeof aggregation === 'boolean');
|
||||
}
|
||||
|
||||
_adaptLayers (requestMapConfig) {
|
||||
return requestMapConfig.layers.map(layer => {
|
||||
if (this._hasLayerAggregation(layer)) {
|
||||
const aggregation = new AggregationProxy(requestMapConfig, layer.options.aggregation);
|
||||
|
||||
let aggregationSql = aggregation.sql();
|
||||
|
||||
const sqlQueryWrap = layer.options.sql_wrap;
|
||||
|
||||
if (sqlQueryWrap) {
|
||||
layer.options.sql_raw = aggregationSql;
|
||||
aggregationSql = sqlQueryWrap.replace(/<%=\s*sql\s*%>/g, aggregationSql);
|
||||
}
|
||||
|
||||
layer.options.sql = aggregationSql;
|
||||
}
|
||||
|
||||
return layer;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user