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