Apply automatic eslint fixes
This commit is contained in:
+22
-22
@@ -7,12 +7,12 @@ module.exports.getQueryActualRowCount = function (query) {
|
||||
return `select COUNT(*) AS rows FROM (${substituteDummyTokens(query)}) AS __cdb_query`;
|
||||
};
|
||||
|
||||
function getQueryRowEstimation(query) {
|
||||
function getQueryRowEstimation (query) {
|
||||
return 'select CDB_EstimateRowCount($windshaft$' + substituteDummyTokens(query) + '$windshaft$) as rows';
|
||||
}
|
||||
module.exports.getQueryRowEstimation = getQueryRowEstimation;
|
||||
|
||||
function getQueryGeometryType(query, geometryColumn) {
|
||||
function getQueryGeometryType (query, geometryColumn) {
|
||||
return `
|
||||
SELECT ST_GeometryType(${geometryColumn}) AS geom_type
|
||||
FROM (${substituteDummyTokens(query)}) AS __cdb_query
|
||||
@@ -37,33 +37,33 @@ module.exports.getAggregationMetadata = ctx => `
|
||||
`;
|
||||
|
||||
/** Cast the column to epoch */
|
||||
module.exports.columnCastTpl = function columnCastTpl(ctx) {
|
||||
module.exports.columnCastTpl = function columnCastTpl (ctx) {
|
||||
return `date_part('epoch', ${ctx.column})`;
|
||||
};
|
||||
|
||||
/** If the column type is float, ignore any non numeric result (infinity / NaN) */
|
||||
module.exports.handleFloatColumn = function handleFloatColumn(ctx) {
|
||||
return `${!ctx.isFloatColumn ? `${ctx.column}` :
|
||||
`nullif(nullif(nullif(${ctx.column}, 'infinity'::float), '-infinity'::float), 'NaN'::float)`
|
||||
module.exports.handleFloatColumn = function handleFloatColumn (ctx) {
|
||||
return `${!ctx.isFloatColumn ? `${ctx.column}`
|
||||
: `nullif(nullif(nullif(${ctx.column}, 'infinity'::float), '-infinity'::float), 'NaN'::float)`
|
||||
}`;
|
||||
};
|
||||
|
||||
/** Count NULL appearances */
|
||||
module.exports.countNULLs = function countNULLs(ctx) {
|
||||
module.exports.countNULLs = function countNULLs (ctx) {
|
||||
return `sum(CASE WHEN (${ctx.column} IS NULL) THEN 1 ELSE 0 END)`;
|
||||
};
|
||||
|
||||
/** Count only infinity (positive and negative) appearances */
|
||||
module.exports.countInfinites = function countInfinites(ctx) {
|
||||
return `${!ctx.isFloatColumn ? '0' :
|
||||
`sum(CASE WHEN (${ctx.column} = 'infinity'::float OR ${ctx.column} = '-infinity'::float) THEN 1 ELSE 0 END)`
|
||||
module.exports.countInfinites = function countInfinites (ctx) {
|
||||
return `${!ctx.isFloatColumn ? '0'
|
||||
: `sum(CASE WHEN (${ctx.column} = 'infinity'::float OR ${ctx.column} = '-infinity'::float) THEN 1 ELSE 0 END)`
|
||||
}`;
|
||||
};
|
||||
|
||||
/** Count only NaNs appearances*/
|
||||
module.exports.countNaNs = function countNaNs(ctx) {
|
||||
return `${!ctx.isFloatColumn ? '0' :
|
||||
`sum(CASE WHEN (${ctx.column} = 'NaN'::float) THEN 1 ELSE 0 END)`
|
||||
/** Count only NaNs appearances */
|
||||
module.exports.countNaNs = function countNaNs (ctx) {
|
||||
return `${!ctx.isFloatColumn ? '0'
|
||||
: `sum(CASE WHEN (${ctx.column} = 'NaN'::float) THEN 1 ELSE 0 END)`
|
||||
}`;
|
||||
};
|
||||
|
||||
@@ -78,7 +78,7 @@ module.exports.getQueryTopCategories = function (query, column, topN, includeNul
|
||||
`;
|
||||
};
|
||||
|
||||
function columnSelector(columns) {
|
||||
function columnSelector (columns) {
|
||||
if (!columns) {
|
||||
return '*';
|
||||
}
|
||||
@@ -110,7 +110,7 @@ module.exports.getSampleFromIdsQuery = function (query, ids, columns, column = '
|
||||
`;
|
||||
};
|
||||
|
||||
function getQueryLimited(query, limit = 0) {
|
||||
function getQueryLimited (query, limit = 0) {
|
||||
return `
|
||||
SELECT *
|
||||
FROM (${substituteDummyTokens(query)}) AS __cdb_query
|
||||
@@ -118,20 +118,20 @@ function getQueryLimited(query, limit = 0) {
|
||||
`;
|
||||
}
|
||||
|
||||
function queryPromise(dbConnection, query) {
|
||||
function queryPromise (dbConnection, query) {
|
||||
return new Promise((resolve, reject) => {
|
||||
dbConnection.query(query, (err, res) => err ? reject(err) : resolve(res));
|
||||
dbConnection.query(query, (err, res) => err ? reject(err) : resolve(res));
|
||||
});
|
||||
}
|
||||
|
||||
function substituteDummyTokens(sql) {
|
||||
function substituteDummyTokens (sql) {
|
||||
return SubstitutionTokens.replace(sql);
|
||||
}
|
||||
|
||||
function substituteTokensForZoom(sql, zoom) {
|
||||
const extent = new WebMercatorHelper().getExtent({ x : 0, y : 0, z : 0 });
|
||||
function substituteTokensForZoom (sql, zoom) {
|
||||
const extent = new WebMercatorHelper().getExtent({ x: 0, y: 0, z: 0 });
|
||||
const bbox = `ST_MakeEnvelope(${extent.xmin}, ${extent.ymin}, ${extent.xmax}, ${extent.ymax}, 3857)`;
|
||||
return SubstitutionTokens.replaceXYZ(sql, { z : zoom, bbox: bbox });
|
||||
return SubstitutionTokens.replaceXYZ(sql, { z: zoom, bbox: bbox });
|
||||
}
|
||||
|
||||
module.exports.queryPromise = queryPromise;
|
||||
|
||||
Reference in New Issue
Block a user