Merge branch 'master' into eslint
This commit is contained in:
@@ -94,6 +94,8 @@ var CATEGORIES_LIMIT = 6;
|
||||
function Aggregation (query, options, queryRewriter, queryRewriteData, params, queries) {
|
||||
BaseOverviewsDataview.call(this, query, options, BaseDataview, queryRewriter, queryRewriteData, params, queries);
|
||||
|
||||
this._checkOptions(options);
|
||||
|
||||
this.query = query;
|
||||
this.queries = queries;
|
||||
this.column = options.column;
|
||||
@@ -219,7 +221,27 @@ var aggregationFnQueryTpl = {
|
||||
sum: dot.template('sum({{=it._aggregationColumn}}*_feature_count)')
|
||||
};
|
||||
|
||||
Aggregation.prototype.getAggregationSql = function () {
|
||||
const VALID_OPERATIONS = {
|
||||
count: [],
|
||||
sum: ['aggregationColumn']
|
||||
};
|
||||
|
||||
Aggregation.prototype._checkOptions = function (options) {
|
||||
if (!VALID_OPERATIONS[options.aggregation]) {
|
||||
throw new Error(`Aggregation does not support '${options.aggregation}' operation in dataview overview options`);
|
||||
}
|
||||
|
||||
const requiredOptions = VALID_OPERATIONS[options.aggregation];
|
||||
const missingOptions = requiredOptions.filter(requiredOption => !options.hasOwnProperty(requiredOption));
|
||||
|
||||
if (missingOptions.length > 0) {
|
||||
throw new Error(
|
||||
`Aggregation '${options.aggregation}' is missing some options for overview: ${missingOptions.join(',')}`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Aggregation.prototype.getAggregationSql = function() {
|
||||
return aggregationFnQueryTpl[this.aggregation]({
|
||||
_aggregationFn: this.aggregation,
|
||||
_aggregationColumn: this.aggregationColumn || 1
|
||||
|
||||
@@ -89,7 +89,12 @@ MapConfigNamedLayersAdapter.prototype.getMapConfig = function (user, requestMapC
|
||||
layers.push(layer);
|
||||
if (layersResult.datasource) {
|
||||
datasourceBuilder.withLayerDatasource(currentLayerIndex, {
|
||||
user: dbAuth.dbuser
|
||||
user: dbAuth.dbuser,
|
||||
// Used internally (PSQL)
|
||||
pass: dbAuth.dbpassword,
|
||||
dbpassword: dbAuth.dbpassword,
|
||||
// Used by Mapnik
|
||||
password: dbAuth.dbpassword
|
||||
});
|
||||
}
|
||||
currentLayerIndex++;
|
||||
|
||||
@@ -242,7 +242,7 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider {
|
||||
}
|
||||
|
||||
dbParams.dbuser = databaseParams.dbuser;
|
||||
dbParams.dbpass = databaseParams.dbpass;
|
||||
dbParams.dbpassword = databaseParams.dbpassword;
|
||||
dbParams.dbhost = databaseParams.dbhost;
|
||||
dbParams.dbport = databaseParams.dbport;
|
||||
dbParams.dbname = databaseParams.dbname;
|
||||
|
||||
Reference in New Issue
Block a user