camel case

This commit is contained in:
Daniel García Aubert
2019-11-14 12:17:26 +01:00
parent f9082dad94
commit d4719d5707
19 changed files with 139 additions and 139 deletions
+4 -4
View File
@@ -32,15 +32,15 @@ AuthBackend.prototype.authorizedBySigner = function (req, res, callback) {
var self = this;
var layergroup_id = res.locals.token;
var auth_token = req.query.auth_token;
var layergroupId = res.locals.token;
var authToken = req.query.auth_token;
this.mapStore.load(layergroup_id, function (err, mapConfig) {
this.mapStore.load(layergroupId, function (err, mapConfig) {
if (err) {
return callback(err);
}
var authorized = self.templateMaps.isAuthorized(mapConfig.obj().template, auth_token);
var authorized = self.templateMaps.isAuthorized(mapConfig.obj().template, authToken);
return callback(null, authorized);
});
+3 -3
View File
@@ -223,12 +223,12 @@ function validateExpressions (expressions) {
throw new Error('Invalid aggregation input, expressions should be and object with valid functions');
}
for (const { aggregate_function, aggregated_column } of Object.values(expressions)) {
if (typeof aggregated_column !== 'string') {
for (const { aggregate_function: aggregateFunction, aggregated_column: aggregatedColumn } of Object.values(expressions)) {
if (typeof aggregatedColumn !== 'string') {
throw new Error('Invalid aggregation input, aggregated column should be an string');
}
if (typeof aggregate_function !== 'string') {
if (typeof aggregateFunction !== 'string') {
throw new Error('Invalid aggregation input, aggregate function should be an string');
}
}
+2 -2
View File
@@ -115,7 +115,7 @@ function getQueryRewriteData (mapConfig, dataviewDefinition, params) {
}
if (params.bbox && queryRewriteData) {
var bbox_filter_definition = {
var bboxFilterDefinition = {
type: 'bbox',
options: {
column: 'the_geom_webmercator',
@@ -125,7 +125,7 @@ function getQueryRewriteData (mapConfig, dataviewDefinition, params) {
bbox: params.bbox
}
};
queryRewriteData = _.extend(queryRewriteData, { bbox_filter: bbox_filter_definition });
queryRewriteData = _.extend(queryRewriteData, { bbox_filter: bboxFilterDefinition });
}
return queryRewriteData;
+7 -7
View File
@@ -10,24 +10,24 @@ function FilterStatsBackends (pgQueryRunner) {
module.exports = FilterStatsBackends;
function getEstimatedRows (pgQueryRunner, username, query, callback) {
pgQueryRunner.run(username, 'EXPLAIN (FORMAT JSON)' + query, function (err, result_rows) {
pgQueryRunner.run(username, 'EXPLAIN (FORMAT JSON)' + query, function (err, resultRows) {
if (err) {
callback(err);
return;
}
var rows;
if (result_rows[0] && result_rows[0]['QUERY PLAN'] &&
result_rows[0]['QUERY PLAN'][0] && result_rows[0]['QUERY PLAN'][0].Plan) {
rows = result_rows[0]['QUERY PLAN'][0].Plan['Plan Rows'];
if (resultRows[0] && resultRows[0]['QUERY PLAN'] &&
resultRows[0]['QUERY PLAN'][0] && resultRows[0]['QUERY PLAN'][0].Plan) {
rows = resultRows[0]['QUERY PLAN'][0].Plan['Plan Rows'];
}
return callback(null, rows);
});
}
FilterStatsBackends.prototype.getFilterStats = function (username, unfiltered_query, filters, callback) {
FilterStatsBackends.prototype.getFilterStats = function (username, unfilteredQuery, filters, callback) {
var stats = {};
getEstimatedRows(this.pgQueryRunner, username, unfiltered_query, (err, rows) => {
getEstimatedRows(this.pgQueryRunner, username, unfilteredQuery, (err, rows) => {
if (err) {
return callback(err);
}
@@ -39,7 +39,7 @@ FilterStatsBackends.prototype.getFilterStats = function (username, unfiltered_qu
}
var analysisFilter = new AnalysisFilter(filters);
var query = analysisFilter.sql(unfiltered_query);
var query = analysisFilter.sql(unfilteredQuery);
getEstimatedRows(this.pgQueryRunner, username, query, (err, rows) => {
if (err) {
+27 -27
View File
@@ -12,7 +12,7 @@ var util = require('util');
//
// See http://github.com/CartoDB/Windshaft-cartodb/wiki/Template-maps
//
// @param redis_pool an instance of a "redis-mpool"
// @param redisPool an instance of a "redis-mpool"
// See https://github.com/CartoDB/node-redis-mpool
// Needs version 0.x.x of the API.
//
@@ -20,14 +20,14 @@ var util = require('util');
// 'max_user_templates' limit on the number of per-user
//
//
function TemplateMaps (redis_pool, opts) {
function TemplateMaps (redisPool, opts) {
if (!(this instanceof TemplateMaps)) {
return new TemplateMaps();
}
EventEmitter.call(this);
this.redis_pool = redis_pool;
this.redisPool = redisPool;
this.opts = opts || {};
// Database containing templates
@@ -44,7 +44,7 @@ function TemplateMaps (redis_pool, opts) {
//
// 1. User templates: set of per-user map templates
// User templates (HASH:tpl_id->tpl_val)
// User templates (HASH:tplId->tpl_val)
this.key_usr_tpl = dot.template('map_tpl|{{=it.owner}}');
}
@@ -66,13 +66,13 @@ TemplateMaps.prototype._userTemplateLimit = function () {
* @param callback - function to pass results too.
*/
TemplateMaps.prototype._redisCmd = function (redisFunc, redisArgs, callback) {
this.redis_pool.acquire(this.db_signatures, (err, redisClient) => {
this.redisPool.acquire(this.db_signatures, (err, redisClient) => {
if (err) {
return callback(err);
}
redisClient[redisFunc.toUpperCase()](...redisArgs, (err, data) => {
this.redis_pool.release(this.db_signatures, redisClient);
this.redisPool.release(this.db_signatures, redisClient);
if (err) {
return callback(err);
}
@@ -215,7 +215,7 @@ TemplateMaps.prototype._checkUserTemplatesLimit = function (userTemplatesKey, ow
// @param template layergroup template, see
// http://github.com/CartoDB/Windshaft-cartodb/wiki/Template-maps#template-format
//
// @param callback function(err, tpl_id)
// @param callback function(err, tplId)
// Return template identifier (only valid for given user)
//
TemplateMaps.prototype.addTemplate = function (owner, template, callback) {
@@ -260,22 +260,22 @@ TemplateMaps.prototype.addTemplate = function (owner, template, callback) {
//
// @param owner cartodb username of the template owner
//
// @param tpl_id template identifier as returned
// @param tplId template identifier as returned
// by addTemplate or listTemplates
//
// @param callback function(err)
//
TemplateMaps.prototype.delTemplate = function (owner, tpl_id, callback) {
this._redisCmd('HDEL', [this.key_usr_tpl({ owner: owner }), tpl_id], (err, deleted) => {
TemplateMaps.prototype.delTemplate = function (owner, tplId, callback) {
this._redisCmd('HDEL', [this.key_usr_tpl({ owner: owner }), tplId], (err, deleted) => {
if (err) {
return callback(err);
}
if (!deleted) {
return callback(new Error(`Template '${tpl_id}' of user '${owner}' does not exist`));
return callback(new Error(`Template '${tplId}' of user '${owner}' does not exist`));
}
this.emit('delete', owner, tpl_id);
this.emit('delete', owner, tplId);
return callback();
});
};
@@ -289,14 +289,14 @@ TemplateMaps.prototype.delTemplate = function (owner, tpl_id, callback) {
//
// @param owner cartodb username of the template owner
//
// @param tpl_id template identifier as returned by addTemplate
// @param tplId template identifier as returned by addTemplate
//
// @param template layergroup template, see
// http://github.com/CartoDB/Windshaft-cartodb/wiki/Template-maps#template-format
//
// @param callback function(err)
//
TemplateMaps.prototype.updTemplate = function (owner, tpl_id, template, callback) {
TemplateMaps.prototype.updTemplate = function (owner, tplId, template, callback) {
template = templateDefaults(template);
var invalidError = this._checkInvalidTemplate(template);
@@ -304,19 +304,19 @@ TemplateMaps.prototype.updTemplate = function (owner, tpl_id, template, callback
return callback(invalidError);
}
if (tpl_id !== template.name) {
return callback(new Error(`Cannot update name of a map template ('${tpl_id}' != '${template.name}')`));
if (tplId !== template.name) {
return callback(new Error(`Cannot update name of a map template ('${tplId}' != '${template.name}')`));
}
var userTemplatesKey = this.key_usr_tpl({ owner });
this._redisCmd('HGET', [userTemplatesKey, tpl_id], (err, beforeUpdateTemplate) => {
this._redisCmd('HGET', [userTemplatesKey, tplId], (err, beforeUpdateTemplate) => {
if (err) {
return callback(err);
}
if (!beforeUpdateTemplate) {
return callback(new Error(`Template '${tpl_id}' of user '${owner}' does not exist`));
return callback(new Error(`Template '${tplId}' of user '${owner}' does not exist`));
}
let templateString;
@@ -355,7 +355,7 @@ TemplateMaps.prototype.updTemplate = function (owner, tpl_id, template, callback
//
// @param owner cartodb username of the templates owner
//
// @param callback function(err, tpl_id_list)
// @param callback function(err, tplId_list)
// Returns a list of template identifiers
//
TemplateMaps.prototype.listTemplates = function (owner, callback) {
@@ -366,14 +366,14 @@ TemplateMaps.prototype.listTemplates = function (owner, callback) {
//
// @param owner cartodb username of the template owner
//
// @param tpl_id template identifier as returned
// @param tplId template identifier as returned
// by addTemplate or listTemplates
//
// @param callback function(err, template)
// Return full template definition
//
TemplateMaps.prototype.getTemplate = function (owner, tpl_id, callback) {
this._redisCmd('HGET', [this.key_usr_tpl({ owner: owner }), tpl_id], (err, template) => {
TemplateMaps.prototype.getTemplate = function (owner, tplId, callback) {
this._redisCmd('HGET', [this.key_usr_tpl({ owner: owner }), tplId], (err, template) => {
if (err) {
return callback(err);
}
@@ -446,7 +446,7 @@ function isObject (val) {
}
TemplateMaps.prototype.instance = function (template, params) {
var all_params = {};
var allParams = {};
var phold = template.placeholders || {};
Object.keys(phold).forEach(function (k) {
var val = Object.prototype.hasOwnProperty.call(params, k) ? params[k] : phold[k].default;
@@ -473,7 +473,7 @@ TemplateMaps.prototype.instance = function (template, params) {
// NOTE: should be checked at template create/update time
throw new Error("Invalid placeholder type '" + type + "'");
}
all_params[k] = val;
allParams[k] = val;
});
// NOTE: we're deep-cloning the layergroup here
@@ -481,7 +481,7 @@ TemplateMaps.prototype.instance = function (template, params) {
if (layergroup.buffersize && isObject(layergroup.buffersize)) {
Object.keys(layergroup.buffersize).forEach(function (k) {
layergroup.buffersize[k] = parseInt(_replaceVars(layergroup.buffersize[k], all_params), 10);
layergroup.buffersize[k] = parseInt(_replaceVars(layergroup.buffersize[k], allParams), 10);
});
}
@@ -492,10 +492,10 @@ TemplateMaps.prototype.instance = function (template, params) {
// dynamic styling for this layer
lyropt.cartocss = params.styles[i];
} else if (lyropt.cartocss) {
lyropt.cartocss = _replaceVars(lyropt.cartocss, all_params);
lyropt.cartocss = _replaceVars(lyropt.cartocss, allParams);
}
if (lyropt.sql) {
lyropt.sql = _replaceVars(lyropt.sql, all_params);
lyropt.sql = _replaceVars(lyropt.sql, allParams);
}
// Anything else ?
}