diff --git a/lib/models/dataview/histograms/numeric-histogram.js b/lib/models/dataview/histograms/numeric-histogram.js index 54bee6d7..6f17b59b 100644 --- a/lib/models/dataview/histograms/numeric-histogram.js +++ b/lib/models/dataview/histograms/numeric-histogram.js @@ -80,35 +80,35 @@ module.exports = class NumericHistogram extends BaseHistogram { * ctx.maxBins - If !full max bins to calculate [Optional] */ _buildQueryTpl (ctx) { - var extra_tables = ''; - var extra_queries = ''; - var extra_groupby = ''; - var extra_filter = ''; + var extraTables = ''; + var extraQueries = ''; + var extraGroupBy = ''; + var extraFilter = ''; if (ctx.start < ctx.end) { - extra_filter = ` + extraFilter = ` WHERE __ctx_query.${ctx.column} >= ${ctx.start} AND __ctx_query.${ctx.column} <= ${ctx.end} `; } else { ctx.end = '__cdb_basics.__cdb_max_val'; ctx.start = '__cdb_basics.__cdb_min_val'; - extra_groupby = ', __cdb_basics.__cdb_max_val, __cdb_basics.__cdb_min_val'; - extra_tables = ', __cdb_basics'; - extra_queries = `WITH ${irqQueryTpl(ctx)}`; + extraGroupBy = ', __cdb_basics.__cdb_max_val, __cdb_basics.__cdb_min_val'; + extraTables = ', __cdb_basics'; + extraQueries = `WITH ${irqQueryTpl(ctx)}`; } if (ctx.bins <= 0) { ctx.bins = '__cdb_basics.__cdb_bins_number'; ctx.irq = `percentile_disc(0.75) within group (order by ${ctx.column}) - percentile_disc(0.25) within group (order by ${ctx.column})`; - extra_groupby += ', __cdb_basics.__cdb_bins_number'; - extra_tables = ', __cdb_basics'; - extra_queries = `WITH ${irqQueryTpl(ctx)}`; + extraGroupBy += ', __cdb_basics.__cdb_bins_number'; + extraTables = ', __cdb_basics'; + extraQueries = `WITH ${irqQueryTpl(ctx)}`; } return ` -${extra_queries} +${extraQueries} SELECT (${ctx.end} - ${ctx.start}) / ${ctx.bins}::float AS bin_width, ${ctx.bins} as bins_number, @@ -127,9 +127,9 @@ SELECT END AS bin FROM ( - SELECT * FROM (${ctx.query}) __ctx_query${extra_tables} ${extra_filter} -) __cdb_filtered_source_query${extra_tables} -GROUP BY 10${extra_groupby} + SELECT * FROM (${ctx.query}) __ctx_query${extraTables} ${extraFilter} +) __cdb_filtered_source_query${extraTables} +GROUP BY 10${extraGroupBy} ORDER BY 10;`; } @@ -140,31 +140,31 @@ ORDER BY 10;`; _getSummary (result, override) { const firstRow = result.rows[0] || {}; - var total_nulls = 0; - var total_infinities = 0; - var total_nans = 0; - var total_avg = 0; - var total_count = 0; + var totalNulls = 0; + var totalInfinities = 0; + var totalNans = 0; + var totalAvg = 0; + var totalCount = 0; result.rows.forEach(function (row) { - total_nulls += row.nulls_count; - total_infinities += row.infinities_count; - total_nans += row.nans_count; - total_avg += row.avg * row.freq; - total_count += row.freq; + totalNulls += row.nulls_count; + totalInfinities += row.infinities_count; + totalNans += row.nans_count; + totalAvg += row.avg * row.freq; + totalCount += row.freq; }); - if (total_count !== 0) { - total_avg /= total_count; + if (totalCount !== 0) { + totalAvg /= totalCount; } return { bin_width: firstRow.bin_width, bins_count: firstRow.bins_number, bins_start: this._populateBinStart(firstRow, override), - nulls: total_nulls, - infinities: total_infinities, - nans: total_nans, - avg: total_avg + nulls: totalNulls, + infinities: totalInfinities, + nans: totalNans, + avg: totalAvg }; } diff --git a/lib/models/dataview/overviews/base.js b/lib/models/dataview/overviews/base.js index 39e9bc99..f1bf03f6 100644 --- a/lib/models/dataview/overviews/base.js +++ b/lib/models/dataview/overviews/base.js @@ -53,8 +53,8 @@ BaseOverviewsDataview.prototype.zoomLevelForBbox = function (bbox) { }; BaseOverviewsDataview.prototype.rewrittenQuery = function (query) { - var zoom_level = this.zoomLevelForBbox(this.options.bbox); - return this.queryRewriter.query(query, this.queryRewriteData, { zoom_level: zoom_level }); + var zoomLevel = this.zoomLevelForBbox(this.options.bbox); + return this.queryRewriter.query(query, this.queryRewriteData, { zoom_level: zoomLevel }); }; // Default behaviour diff --git a/lib/models/mapconfig/adapter/mapconfig-overviews-adapter.js b/lib/models/mapconfig/adapter/mapconfig-overviews-adapter.js index d071d2de..3cb39a50 100644 --- a/lib/models/mapconfig/adapter/mapconfig-overviews-adapter.js +++ b/lib/models/mapconfig/adapter/mapconfig-overviews-adapter.js @@ -115,12 +115,12 @@ function getUnfilteredQuery (analysesResults, layer) { if (node) { var filters = node.getFilters(); - var filters_disabler = Object.keys(filters).reduce(function (disabler, filter_id) { - disabler[filter_id] = false; + var filtersDisabler = Object.keys(filters).reduce(function (disabler, filterId) { + disabler[filterId] = false; return disabler; }, {}); - return node.getQuery(filters_disabler); + return node.getQuery(filtersDisabler); } } } diff --git a/lib/stats/client.js b/lib/stats/client.js index 00b47b34..435be5ad 100644 --- a/lib/stats/client.js +++ b/lib/stats/client.js @@ -25,16 +25,16 @@ module.exports = { instance = new StatsD(config); instance.last_error = { msg: '', count: 0 }; instance.socket.on('error', function (err) { - var last_err = instance.last_error; - var last_msg = last_err.msg; - var this_msg = '' + err; - if (this_msg !== last_msg) { + var lastErr = instance.last_error; + var lastMsg = lastErr.msg; + var thisMsg = '' + err; + if (thisMsg !== lastMsg) { debug('statsd client socket error: ' + err); instance.last_error.count = 1; - instance.last_error.msg = this_msg; + instance.last_error.msg = thisMsg; } else { - ++last_err.count; - if (!last_err.interval) { + ++lastErr.count; + if (!lastErr.interval) { instance.last_error.interval = setInterval(function () { var count = instance.last_error.count; if (count > 1) { diff --git a/lib/utils/table-name-parser.js b/lib/utils/table-name-parser.js index 110cb999..db9ad72d 100644 --- a/lib/utils/table-name-parser.js +++ b/lib/utils/table-name-parser.js @@ -1,7 +1,7 @@ 'use strict'; // Quote an PostgreSQL identifier if ncecessary -function quote_identifier_if_needed (txt) { +function quoteIdentifierIfNeeded (txt) { if (txt && !txt.match(/^[a-z_][a-z_0-9]*$/)) { return '"' + txt.replace(/"/g, '""') + '"'; } else { @@ -10,13 +10,13 @@ function quote_identifier_if_needed (txt) { } // Parse PostgreSQL table name (possibly quoted and with optional schema).+ -// Returns { schema: 'schema_name', table: 'table_name' } -function parse_table_name (table) { - function split_as_quoted_parts (table_name) { +// Returns { schema: 'schema_name', table: 'tableName' } +function parseTableName (table) { + function splitAsQuotedParts (tableName) { // parse table into 'parts' that may be quoted, each part // in the parts array being an object { part: 'text', quoted: false/true } var parts = []; - var splitted = table_name.split(/"/); + var splitted = tableName.split(/"/); for (var i = 0; i < splitted.length; i++) { if (splitted[i] === '') { if (parts.length > 0 && i < splitted.length - 1) { @@ -24,61 +24,61 @@ function parse_table_name (table) { parts[parts.length - 1].part += '"' + splitted[i]; } } else { - var is_quoted = (i > 0 && splitted[i - 1] === '') || + var isQuoted = (i > 0 && splitted[i - 1] === '') || (i < splitted.length - 1 && splitted[i + 1] === ''); - parts.push({ part: splitted[i], quoted: is_quoted }); + parts.push({ part: splitted[i], quoted: isQuoted }); } } return parts; } - var parts = split_as_quoted_parts(table); + var parts = splitAsQuotedParts(table); - function split_single_part (part) { - var schema_part = null; - var table_part = null; + function splitSinglePart (part) { + var schemaPart = null; + var tablePart = null; if (part.quoted) { - table_part = part.part; + tablePart = part.part; } else { var parts = part.part.split('.'); if (parts.length === 1) { - schema_part = null; - table_part = parts[0]; + schemaPart = null; + tablePart = parts[0]; } else if (parts.length === 2) { - schema_part = parts[0]; - table_part = parts[1]; + schemaPart = parts[0]; + tablePart = parts[1]; } // else invalid table name } return { - schema: schema_part, - table: table_part + schema: schemaPart, + table: tablePart }; } - function split_two_parts (part1, part2) { - var schema_part = null; - var table_part = null; + function splitTwoParts (part1, part2) { + var schemaPart = null; + var tablePart = null; if (part1.quoted && !part2.quoted) { if (part2.part[0] === '.') { - schema_part = part1.part; - table_part = part2.part.slice(1); + schemaPart = part1.part; + tablePart = part2.part.slice(1); } // else invalid table name (missing dot) } else if (!part1.quoted && part2.quoted) { if (part1.part[part1.part.length - 1] === '.') { - schema_part = part1.part.slice(0, -1); - table_part = part2.part; + schemaPart = part1.part.slice(0, -1); + tablePart = part2.part; } // else invalid table name (missing dot) } // else invalid table name (missing dot) return { - schema: schema_part, - table: table_part + schema: schemaPart, + table: tablePart }; } if (parts.length === 1) { - return split_single_part(parts[0]); + return splitSinglePart(parts[0]); } else if (parts.length === 2) { - return split_two_parts(parts[0], parts[1]); + return splitTwoParts(parts[0], parts[1]); } else if (parts.length === 3 && parts[1].part === '.') { return { schema: parts[0].part, @@ -87,12 +87,12 @@ function parse_table_name (table) { } // else invalid table name } -function table_identifier (parsed_name) { - if (parsed_name && parsed_name.table) { - if (parsed_name.schema) { - return quote_identifier_if_needed(parsed_name.schema) + '.' + quote_identifier_if_needed(parsed_name.table); +function tableIdentifier (parsedName) { + if (parsedName && parsedName.table) { + if (parsedName.schema) { + return quoteIdentifierIfNeeded(parsedName.schema) + '.' + quoteIdentifierIfNeeded(parsedName.table); } else { - return quote_identifier_if_needed(parsed_name.table); + return quoteIdentifierIfNeeded(parsedName.table); } } else { return null; @@ -100,7 +100,7 @@ function table_identifier (parsed_name) { } module.exports = { - parse: parse_table_name, - quote: quote_identifier_if_needed, - table_identifier: table_identifier + parse: parseTableName, + quote: quoteIdentifierIfNeeded, + table_identifier: tableIdentifier }; diff --git a/test/acceptance/aggregation-test.js b/test/acceptance/aggregation-test.js index 2ca4a00a..9888f696 100644 --- a/test/acceptance/aggregation-test.js +++ b/test/acceptance/aggregation-test.js @@ -607,10 +607,10 @@ describe('aggregation', function () { Object.keys(f.properties).forEach(p => columns.add(p)); }); columns = Array.from(columns); - const expected_columns = [ + const expectedColumns = [ '_cdb_feature_count', 'cartodb_id', 'first_column', 'second_column' ]; - assert.deepStrictEqual(columns.sort(), expected_columns.sort()); + assert.deepStrictEqual(columns.sort(), expectedColumns.sort()); done(); }); @@ -3015,15 +3015,15 @@ describe('aggregation', function () { const tile11 = JSON.parse(mvt.toGeoJSONSync(0)); // There needs to be 13 points - const count_features = (tile) => + const countFeatures = (tile) => tile.features.map(f => f.properties) .map(f => f._cdb_feature_count) .reduce((a, b) => a + b, 0); - const tile00Count = count_features(tile00); - const tile10Count = count_features(tile10); - const tile01Count = count_features(tile01); - const tile11Count = count_features(tile11); + const tile00Count = countFeatures(tile00); + const tile10Count = countFeatures(tile10); + const tile01Count = countFeatures(tile01); + const tile11Count = countFeatures(tile11); assert.strictEqual(13, tile00Count + tile10Count + tile01Count + tile11Count); done(); diff --git a/test/acceptance/analysis/analyses-controller-test.js b/test/acceptance/analysis/analyses-controller-test.js index 31526480..c91dc3a0 100644 --- a/test/acceptance/analysis/analyses-controller-test.js +++ b/test/acceptance/analysis/analyses-controller-test.js @@ -51,7 +51,7 @@ describe('analyses controller', function () { }); it('should support jsonp responses', function (done) { - this.testClient.getAnalysesCatalog({ jsonp: 'jsonp_test' }, (err, result) => { + this.testClient.getAnalysesCatalog({ jsonp: 'jsonpTest' }, (err, result) => { if (err) { return done(err); } @@ -60,7 +60,7 @@ describe('analyses controller', function () { let didRunJsonCallback = false; /* eslint-disable no-unused-vars, no-eval */ - function jsonp_test (body) { + function jsonpTest (body) { assert.ok(Array.isArray(body.catalog)); didRunJsonCallback = true; } diff --git a/test/acceptance/cluster-test.js b/test/acceptance/cluster-test.js index d09d1b23..656c10f2 100644 --- a/test/acceptance/cluster-test.js +++ b/test/acceptance/cluster-test.js @@ -48,7 +48,7 @@ describe('cluster', function () { }]); const testClient = new TestClient(mapConfig); const zoom = 0; - const cartodb_id = 1; + const cartodbId = 1; const layerId = 0; const params = { response: { @@ -56,7 +56,7 @@ describe('cluster', function () { } }; - testClient.getClusterFeatures(zoom, cartodb_id, layerId, params, (err, body) => { + testClient.getClusterFeatures(zoom, cartodbId, layerId, params, (err, body) => { if (err) { return done(err); } @@ -90,7 +90,7 @@ describe('cluster', function () { }]); const testClient = new TestClient(mapConfig); const zoom = 0; - const cartodb_id = 1; + const cartodbId = 1; const layerId = 0; const params = { response: { @@ -98,7 +98,7 @@ describe('cluster', function () { } }; - testClient.getClusterFeatures(zoom, cartodb_id, layerId, params, (err, body) => { + testClient.getClusterFeatures(zoom, cartodbId, layerId, params, (err, body) => { if (err) { return done(err); } @@ -291,8 +291,8 @@ describe('cluster', function () { } ]; - suite.forEach(({ zoom, cartodb_id, resolution, expected }) => { - const description = `should get features for z: ${zoom} cartodb_id: ${cartodb_id}, res: ${resolution}`; + suite.forEach(({ zoom, cartodb_id: cartodbId, resolution, expected }) => { + const description = `should get features for z: ${zoom} cartodb_id: ${cartodbId}, res: ${resolution}`; it(description, function (done) { const mapConfig = createVectorMapConfig([{ type: 'cartodb', @@ -308,7 +308,7 @@ describe('cluster', function () { const layerId = 0; const params = {}; - testClient.getClusterFeatures(zoom, cartodb_id, layerId, params, (err, body) => { + testClient.getClusterFeatures(zoom, cartodbId, layerId, params, (err, body) => { if (err) { return done(err); } @@ -534,8 +534,8 @@ describe('cluster', function () { } ]; - suite.forEach(({ zoom, cartodb_id, resolution, aggregation, expected }) => { - it(`should aggregate by type; z: ${zoom}, cartodb_id: ${cartodb_id}, res: ${resolution}`, function (done) { + suite.forEach(({ zoom, cartodb_id: cartodbId, resolution, aggregation, expected }) => { + it(`should aggregate by type; z: ${zoom}, cartodb_id: ${cartodbId}, res: ${resolution}`, function (done) { const mapConfig = createVectorMapConfig([{ type: 'cartodb', options: { @@ -550,19 +550,19 @@ describe('cluster', function () { const layerId = 0; const params = { aggregation }; - testClient.getClusterFeatures(zoom, cartodb_id, layerId, params, (err, body) => { + testClient.getClusterFeatures(zoom, cartodbId, layerId, params, (err, body) => { if (err) { return done(err); } - const sort_f = (a, b) => { + const sortFn = (a, b) => { return (a._cdb_feature_count < b._cdb_feature_count) || (a._cdb_feature_count === b._cdb_feature_count && (a.type < b.type || (a.type === b.type && a.max_value < b.max_value))); }; - assert.deepStrictEqual(body.rows.sort(sort_f), expected.sort(sort_f)); + assert.deepStrictEqual(body.rows.sort(sortFn), expected.sort(sortFn)); testClient.drain(done); }); @@ -807,7 +807,7 @@ describe('cluster', function () { } ]; - suite.forEach(({ description, zoom, cartodb_id, resolution, aggregation, expected, status = 400 }) => { + suite.forEach(({ description, zoom, cartodb_id: cartodbId, resolution, aggregation, expected, status = 400 }) => { it(description, function (done) { const mapConfig = createVectorMapConfig([{ type: 'cartodb', @@ -826,7 +826,7 @@ describe('cluster', function () { aggregation }; - testClient.getClusterFeatures(zoom, cartodb_id, layerId, params, (err, body) => { + testClient.getClusterFeatures(zoom, cartodbId, layerId, params, (err, body) => { if (err) { return done(err); } diff --git a/test/acceptance/dataviews/aggregation-test.js b/test/acceptance/dataviews/aggregation-test.js index 34f3fa72..c4bb28d8 100644 --- a/test/acceptance/dataviews/aggregation-test.js +++ b/test/acceptance/dataviews/aggregation-test.js @@ -98,9 +98,9 @@ describe('aggregations happy cases', function () { }); }); - var operations_and_values = { count: 9, sum: 45, avg: 5, max: 9, min: 1 }; + var operationsAndValues = { count: 9, sum: 45, avg: 5, max: 9, min: 1 }; - var query_other = [ + var queryOther = [ 'select generate_series(1,3) as val, \'other_a\' as cat, NULL as the_geom_webmercator', 'select generate_series(4,6) as val, \'other_b\' as cat, NULL as the_geom_webmercator', 'select generate_series(7,9) as val, \'other_c\' as cat, NULL as the_geom_webmercator', @@ -111,11 +111,11 @@ describe('aggregations happy cases', function () { 'select generate_series(10,12) as val, \'category_5\' as cat, NULL as the_geom_webmercator' ].join(' UNION ALL '); - Object.keys(operations_and_values).forEach(function (operation) { + Object.keys(operationsAndValues).forEach(function (operation) { var description = 'should aggregate OTHER category using "' + operation + '"'; it(description, function (done) { - this.testClient = new TestClient(aggregationOperationMapConfig(operation, query_other, 'cat', 'val')); + this.testClient = new TestClient(aggregationOperationMapConfig(operation, queryOther, 'cat', 'val')); this.testClient.getDataview('cat', { own_filter: 0 }, function (err, aggregation) { assert.ifError(err); @@ -126,11 +126,11 @@ describe('aggregations happy cases', function () { assert.strictEqual(aggregation.count, 24); assert.strictEqual(aggregation.nulls, 0); - var aggregated_categories = aggregation.categories.filter(function (category) { + var aggregatedCategories = aggregation.categories.filter(function (category) { return category.agg === true; }); - assert.strictEqual(aggregated_categories.length, 1); - assert.strictEqual(aggregated_categories[0].value, operations_and_values[operation]); + assert.strictEqual(aggregatedCategories.length, 1); + assert.strictEqual(aggregatedCategories[0].value, operationsAndValues[operation]); done(); }); @@ -145,11 +145,11 @@ describe('aggregations happy cases', function () { min: [{ category: 'other_a', value: 1 }] }; - Object.keys(operations_and_values).forEach(function (operation) { + Object.keys(operationsAndValues).forEach(function (operation) { var description = 'should search OTHER category using "' + operation + '"'; it(description, function (done) { - this.testClient = new TestClient(aggregationOperationMapConfig(operation, query_other, 'cat', 'val')); + this.testClient = new TestClient(aggregationOperationMapConfig(operation, queryOther, 'cat', 'val')); this.testClient.widgetSearch('cat', 'other_a', function (err, res, searchResult) { assert.ifError(err); diff --git a/test/acceptance/dataviews/histogram-test.js b/test/acceptance/dataviews/histogram-test.js index b71ebcbc..a78c0de7 100644 --- a/test/acceptance/dataviews/histogram-test.js +++ b/test/acceptance/dataviews/histogram-test.js @@ -1482,9 +1482,9 @@ describe('histogram-dates: timestamp starts at epoch', function () { this.testClient.getDataview('epoch_start_histogram', override, function (err, dataview) { assert.ifError(err); - const { aggregation, timestamp_start } = dataview; + const { aggregation, timestamp_start: timestampStart } = dataview; - assert.strictEqual(timestamp_start, 0); + assert.strictEqual(timestampStart, 0); assert.strictEqual(aggregation, 'quarter'); done(); diff --git a/test/acceptance/dataviews/overviews-test.js b/test/acceptance/dataviews/overviews-test.js index e53c5bc4..f46226a8 100644 --- a/test/acceptance/dataviews/overviews-test.js +++ b/test/acceptance/dataviews/overviews-test.js @@ -50,11 +50,11 @@ describe('dataviews using tables without overviews', function () { it('should expose a formula', function (done) { var testClient = new TestClient(nonOverviewsMapConfig); - testClient.getDataview('country_places_count', { own_filter: 0 }, function (err, formula_result, headers) { + testClient.getDataview('country_places_count', { own_filter: 0 }, function (err, formulaResult, headers) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { operation: 'count', result: 7313, nulls: 0, type: 'formula' }); + assert.deepStrictEqual(formulaResult, { operation: 'count', result: 7313, nulls: 0, type: 'formula' }); assert(getUsesOverviewsFromHeaders(headers) === false); // Overviews logging testClient.drain(done); @@ -66,11 +66,11 @@ describe('dataviews using tables without overviews', function () { bbox: '-170,-80,170,80' }; var testClient = new TestClient(nonOverviewsMapConfig); - testClient.getDataview('country_places_count', params, function (err, formula_result) { + testClient.getDataview('country_places_count', params, function (err, formulaResult) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { operation: 'count', result: 7253, nulls: 0, type: 'formula' }); + assert.deepStrictEqual(formulaResult, { operation: 'count', result: 7253, nulls: 0, type: 'formula' }); testClient.drain(done); }); @@ -85,11 +85,11 @@ describe('dataviews using tables without overviews', function () { } }; var testClient = new TestClient(nonOverviewsMapConfig); - testClient.getDataview('country_places_count', params, function (err, formula_result) { + testClient.getDataview('country_places_count', params, function (err, formulaResult) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { operation: 'count', result: 256, nulls: 0, type: 'formula' }); + assert.deepStrictEqual(formulaResult, { operation: 'count', result: 256, nulls: 0, type: 'formula' }); testClient.drain(done); }); }); @@ -102,11 +102,11 @@ describe('dataviews using tables without overviews', function () { bbox: '-170,-80,170,80' }; var testClient = new TestClient(nonOverviewsMapConfig); - testClient.getDataview('country_places_count', params, function (err, formula_result) { + testClient.getDataview('country_places_count', params, function (err, formulaResult) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { operation: 'count', result: 254, nulls: 0, type: 'formula' }); + assert.deepStrictEqual(formulaResult, { operation: 'count', result: 254, nulls: 0, type: 'formula' }); testClient.drain(done); }); }); @@ -257,11 +257,11 @@ describe('dataviews using tables with overviews', function () { it('should expose a sum formula', function (done) { var testClient = new TestClient(overviewsMapConfig); - testClient.getDataview('test_sum', { own_filter: 0 }, function (err, formula_result, headers) { + testClient.getDataview('test_sum', { own_filter: 0 }, function (err, formulaResult, headers) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { + assert.deepStrictEqual(formulaResult, { operation: 'sum', result: 15, infinities: 0, @@ -278,11 +278,11 @@ describe('dataviews using tables with overviews', function () { it('should expose an avg formula', function (done) { var testClient = new TestClient(overviewsMapConfig); - testClient.getDataview('test_avg', { own_filter: 0 }, function (err, formula_result, headers) { + testClient.getDataview('test_avg', { own_filter: 0 }, function (err, formulaResult, headers) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { + assert.deepStrictEqual(formulaResult, { operation: 'avg', result: 3, nulls: 0, @@ -299,11 +299,11 @@ describe('dataviews using tables with overviews', function () { it('should expose a count formula', function (done) { var testClient = new TestClient(overviewsMapConfig); - testClient.getDataview('test_count', { own_filter: 0 }, function (err, formula_result, headers) { + testClient.getDataview('test_count', { own_filter: 0 }, function (err, formulaResult, headers) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { + assert.deepStrictEqual(formulaResult, { operation: 'count', result: 5, nulls: 0, @@ -320,11 +320,11 @@ describe('dataviews using tables with overviews', function () { it('should expose a max formula', function (done) { var testClient = new TestClient(overviewsMapConfig); - testClient.getDataview('test_max', { own_filter: 0 }, function (err, formula_result) { + testClient.getDataview('test_max', { own_filter: 0 }, function (err, formulaResult) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { + assert.deepStrictEqual(formulaResult, { operation: 'max', result: 5, nulls: 0, @@ -339,11 +339,11 @@ describe('dataviews using tables with overviews', function () { it('should expose a min formula', function (done) { var testClient = new TestClient(overviewsMapConfig); - testClient.getDataview('test_min', { own_filter: 0 }, function (err, formula_result) { + testClient.getDataview('test_min', { own_filter: 0 }, function (err, formulaResult) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { + assert.deepStrictEqual(formulaResult, { operation: 'min', result: 1, nulls: 0, @@ -361,11 +361,11 @@ describe('dataviews using tables with overviews', function () { bbox: '-170,-80,170,80' }; var testClient = new TestClient(overviewsMapConfig); - testClient.getDataview('test_sum', params, function (err, formula_result) { + testClient.getDataview('test_sum', params, function (err, formulaResult) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { + assert.deepStrictEqual(formulaResult, { operation: 'sum', result: 15, nulls: 0, @@ -468,11 +468,11 @@ describe('dataviews using tables with overviews', function () { it('should expose a filtered sum formula', function (done) { var testClient = new TestClient(overviewsMapConfig); - testClient.getDataview('test_sum', params, function (err, formula_result, headers) { + testClient.getDataview('test_sum', params, function (err, formulaResult, headers) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { + assert.deepStrictEqual(formulaResult, { operation: 'sum', result: 1, nulls: 0, @@ -487,11 +487,11 @@ describe('dataviews using tables with overviews', function () { it('should expose a filtered avg formula', function (done) { var testClient = new TestClient(overviewsMapConfig); - testClient.getDataview('test_avg', params, function (err, formula_result, headers) { + testClient.getDataview('test_avg', params, function (err, formulaResult, headers) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { + assert.deepStrictEqual(formulaResult, { operation: 'avg', result: 1, nulls: 0, @@ -507,11 +507,11 @@ describe('dataviews using tables with overviews', function () { it('should expose a filtered count formula', function (done) { var testClient = new TestClient(overviewsMapConfig); - testClient.getDataview('test_count', params, function (err, formula_result, headers) { + testClient.getDataview('test_count', params, function (err, formulaResult, headers) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { + assert.deepStrictEqual(formulaResult, { operation: 'count', result: 1, infinities: 0, @@ -527,11 +527,11 @@ describe('dataviews using tables with overviews', function () { it('should expose a filterd max formula', function (done) { var testClient = new TestClient(overviewsMapConfig); - testClient.getDataview('test_max', params, function (err, formula_result) { + testClient.getDataview('test_max', params, function (err, formulaResult) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { + assert.deepStrictEqual(formulaResult, { operation: 'max', result: 1, nulls: 0, @@ -546,11 +546,11 @@ describe('dataviews using tables with overviews', function () { it('should expose a filterd min formula', function (done) { var testClient = new TestClient(overviewsMapConfig); - testClient.getDataview('test_min', params, function (err, formula_result) { + testClient.getDataview('test_min', params, function (err, formulaResult) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { + assert.deepStrictEqual(formulaResult, { operation: 'min', result: 1, nulls: 0, @@ -571,11 +571,11 @@ describe('dataviews using tables with overviews', function () { bbox: '-170,-80,170,80' }; var testClient = new TestClient(overviewsMapConfig); - testClient.getDataview('test_sum', bboxparams, function (err, formula_result) { + testClient.getDataview('test_sum', bboxparams, function (err, formulaResult) { if (err) { return done(err); } - assert.deepStrictEqual(formula_result, { + assert.deepStrictEqual(formulaResult, { operation: 'sum', result: 1, nulls: 0, diff --git a/test/acceptance/date-wrapping-test.js b/test/acceptance/date-wrapping-test.js index 5a0c6713..9f662826 100644 --- a/test/acceptance/date-wrapping-test.js +++ b/test/acceptance/date-wrapping-test.js @@ -6,9 +6,9 @@ const mapConfigFactory = require('../fixtures/test_mapconfigFactory'); const serverOptions = require('../../lib/server-options'); const usePgMvtRenderer = serverOptions.renderer.mvt.usePostGIS; -const describe_mvt = !usePgMvtRenderer ? describe : describe.skip; +const describeMvt = !usePgMvtRenderer ? describe : describe.skip; -describe_mvt('date-wrapping', () => { +describeMvt('date-wrapping', () => { let testClient; describe('when a map instantiation has one single layer', () => { diff --git a/test/acceptance/layergroup-metadata-test.js b/test/acceptance/layergroup-metadata-test.js index 98661f76..1543f230 100644 --- a/test/acceptance/layergroup-metadata-test.js +++ b/test/acceptance/layergroup-metadata-test.js @@ -17,8 +17,8 @@ describe('layergroup metadata', function () { serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS; }); - [1234, 'default_public', false].forEach(api_key => { - it(`tiles base urls ${api_key ? `with api key: ${api_key}` : 'without api key'}`, function (done) { + [1234, 'default_public', false].forEach(apiKey => { + it(`tiles base urls ${apiKey ? `with api key: ${apiKey}` : 'without api key'}`, function (done) { const mapConfig = { version: '1.7.0', layers: [ @@ -33,7 +33,7 @@ describe('layergroup metadata', function () { const host = `https://localhost.localhost.lan:${global.environment.port}`; - const testClient = new TestClient(mapConfig, api_key); + const testClient = new TestClient(mapConfig, apiKey); testClient.getLayergroup((err, body) => { if (err) { return done(err); @@ -42,9 +42,9 @@ describe('layergroup metadata', function () { let urlLayer = `${host}/api/v1/map/${body.layergroupid}/layer0/{z}/{x}/{y}.mvt`; let urlNoLayer = `${host}/api/v1/map/${body.layergroupid}/{z}/{x}/{y}.mvt`; - if (api_key) { - urlLayer += `?api_key=${api_key}`; - urlNoLayer += `?api_key=${api_key}`; + if (apiKey) { + urlLayer += `?api_key=${apiKey}`; + urlNoLayer += `?api_key=${apiKey}`; } assert.ok(body.layergroupid); diff --git a/test/acceptance/layers-filters-test.js b/test/acceptance/layers-filters-test.js index cfac5d03..06700c34 100644 --- a/test/acceptance/layers-filters-test.js +++ b/test/acceptance/layers-filters-test.js @@ -17,11 +17,11 @@ describe('layers filters', function () { marker-fill: red; marker-allow-overlap: true; }`; - const cartocss_version = '3.0.12'; + const cartocssVersion = '3.0.12'; const options = { sql, cartocss, - cartocss_version + cartocss_version: cartocssVersion }; const mapConfig = { diff --git a/test/acceptance/named-layers-test.js b/test/acceptance/named-layers-test.js index e8185352..1ea33e31 100644 --- a/test/acceptance/named-layers-test.js +++ b/test/acceptance/named-layers-test.js @@ -1,6 +1,6 @@ 'use strict'; -var test_helper = require('../support/test-helper'); +var testHelper = require('../support/test-helper'); var assert = require('../support/assert'); var CartodbWindshaft = require('../../lib/server'); @@ -110,7 +110,7 @@ describe('named_layers', function () { }); afterEach(function (done) { - test_helper.deleteRedisKeys(keysToDelete, done); + testHelper.deleteRedisKeys(keysToDelete, done); }); beforeEach(function (done) { @@ -461,7 +461,7 @@ describe('named_layers', function () { if (err) { throw err; } - test_helper.checkCache(res); + testHelper.checkCache(res); return true; }, function deleteTemplate (err) { @@ -590,7 +590,7 @@ describe('named_layers', function () { if (err) { throw err; } - test_helper.checkCache(res); + testHelper.checkCache(res); return true; }, function deleteTemplate (err) { @@ -843,7 +843,7 @@ describe('named_layers', function () { if (err) { throw err; } - test_helper.checkCache(res); + testHelper.checkCache(res); return true; }, function deleteTemplate (err) { diff --git a/test/acceptance/named-layers-visibility-test.js b/test/acceptance/named-layers-visibility-test.js index cafed045..1a717cf8 100644 --- a/test/acceptance/named-layers-visibility-test.js +++ b/test/acceptance/named-layers-visibility-test.js @@ -1,7 +1,7 @@ 'use strict'; var step = require('step'); -var test_helper = require('../support/test-helper'); +var testHelper = require('../support/test-helper'); var assert = require('../support/assert'); var CartodbWindshaft = require('../../lib/server'); @@ -80,7 +80,7 @@ describe('layers visibility for previews', function () { } afterEach(function (done) { - test_helper.deleteRedisKeys({ + testHelper.deleteRedisKeys({ 'user:localhost:mapviews:global': 5 }, done); }); diff --git a/test/acceptance/named-maps-authentication-test.js b/test/acceptance/named-maps-authentication-test.js index f497c99d..848983b2 100644 --- a/test/acceptance/named-maps-authentication-test.js +++ b/test/acceptance/named-maps-authentication-test.js @@ -1,6 +1,6 @@ 'use strict'; -var test_helper = require('../support/test-helper'); +var testHelper = require('../support/test-helper'); var RedisPool = require('redis-mpool'); var querystring = require('querystring'); @@ -195,7 +195,7 @@ describe('named maps authentication', function () { assert.strictEqual(img.height(), 256); assert.ok(!err); - test_helper.checkSurrogateKey(res, new NamedMapsCacheEntry(username, tokenAuthTemplateName).key()); + testHelper.checkSurrogateKey(res, new NamedMapsCacheEntry(username, tokenAuthTemplateName).key()); done(); }); }); @@ -264,8 +264,8 @@ describe('named maps authentication', function () { assert.strictEqual(img.width(), 640); assert.strictEqual(img.height(), 480); - test_helper.checkSurrogateKey(res, new NamedMapsCacheEntry(username, tokenAuthTemplateName).key()); - test_helper.deleteRedisKeys({ 'user:localhost:mapviews:global': 5 }, done); + testHelper.checkSurrogateKey(res, new NamedMapsCacheEntry(username, tokenAuthTemplateName).key()); + testHelper.deleteRedisKeys({ 'user:localhost:mapviews:global': 5 }, done); }); }); }); diff --git a/test/acceptance/named-maps-stats-test.js b/test/acceptance/named-maps-stats-test.js index 0d5fe9fc..6ccf112e 100644 --- a/test/acceptance/named-maps-stats-test.js +++ b/test/acceptance/named-maps-stats-test.js @@ -1,6 +1,6 @@ 'use strict'; -var test_helper = require('../support/test-helper'); +var testHelper = require('../support/test-helper'); var RedisPool = require('redis-mpool'); var querystring = require('querystring'); @@ -106,10 +106,10 @@ describe('named maps preview stats', function () { assert.strictEqual(img.width(), 640); assert.strictEqual(img.height(), 480); - test_helper.checkSurrogateKey(res, new NamedMapsCacheEntry(username, templateName).key()); + testHelper.checkSurrogateKey(res, new NamedMapsCacheEntry(username, templateName).key()); var redisKeysToDelete = { 'user:localhost:mapviews:global': 5 }; redisKeysToDelete['user:localhost:mapviews:stat_tag:' + statTag] = 5; - test_helper.deleteRedisKeys(redisKeysToDelete, done); + testHelper.deleteRedisKeys(redisKeysToDelete, done); }); }); }); diff --git a/test/acceptance/overviews-metadata-named-maps-test.js b/test/acceptance/overviews-metadata-named-maps-test.js index 1676203f..cbab9289 100644 --- a/test/acceptance/overviews-metadata-named-maps-test.js +++ b/test/acceptance/overviews-metadata-named-maps-test.js @@ -1,6 +1,6 @@ 'use strict'; -var test_helper = require('../support/test-helper'); +var testHelper = require('../support/test-helper'); var assert = require('../support/assert'); var CartodbWindshaft = require('../../lib/server'); @@ -24,7 +24,7 @@ describe('overviews metadata for named maps', function () { // configure redis pool instance to use in tests var redisPool = new RedisPool(global.environment.redis); - var overviews_layer = { + var overviewsLayer = { type: 'cartodb', options: { sql: 'SELECT * FROM test_table_overviews', @@ -33,7 +33,7 @@ describe('overviews metadata for named maps', function () { } }; - var non_overviews_layer = { + var nonOverviewsLayer = { type: 'cartodb', options: { sql: 'SELECT * FROM test_table', @@ -49,7 +49,7 @@ describe('overviews metadata for named maps', function () { }); afterEach(function (done) { - test_helper.deleteRedisKeys(keysToDelete, done); + testHelper.deleteRedisKeys(keysToDelete, done); }); var templateId = 'overviews-template-1'; @@ -60,7 +60,7 @@ describe('overviews metadata for named maps', function () { auth: { method: 'open' }, layergroup: { version: '1.0.0', - layers: [overviews_layer, non_overviews_layer] + layers: [overviewsLayer, nonOverviewsLayer] } }; @@ -133,10 +133,10 @@ describe('overviews metadata for named maps', function () { }); mapStore.load(LayergroupToken.parse(layergroupId).token, function (err, mapConfig) { assert.ifError(err); - assert.deepStrictEqual(non_overviews_layer, mapConfig._cfg.layers[1]); + assert.deepStrictEqual(nonOverviewsLayer, mapConfig._cfg.layers[1]); assert.strictEqual(mapConfig._cfg.layers[0].type, 'cartodb'); assert.ok(mapConfig._cfg.layers[0].options.query_rewrite_data); - var expected_data = { + var expectedData = { overviews: { test_table_overviews: { schema: 'public', @@ -145,7 +145,7 @@ describe('overviews metadata for named maps', function () { } } }; - assert.deepStrictEqual(mapConfig._cfg.layers[0].options.query_rewrite_data, expected_data); + assert.deepStrictEqual(mapConfig._cfg.layers[0].options.query_rewrite_data, expectedData); }); next(err); @@ -240,7 +240,7 @@ describe('overviews metadata for named maps', function () { auth: { method: 'open' }, layergroup: { version: '1.0.0', - layers: [non_overviews_layer] + layers: [nonOverviewsLayer] } };