Fix eslint issues

This commit is contained in:
Daniel García Aubert 2019-11-06 13:56:59 +01:00
parent 27106fea57
commit cc24228511
11 changed files with 239 additions and 278 deletions

View File

@ -44,7 +44,8 @@ module.exports = class Histogram {
}
_isDateHistogram (override = {}) {
return (Object.prototype.hasOwnProperty.call(this.options, 'aggregation') || override.hasOwnProperty('aggregation'));
return (Object.prototype.hasOwnProperty.call(this.options, 'aggregation') ||
Object.prototype.hasOwnProperty.call(override, 'aggregation'));
}
getResult (psql, override, callback) {

View File

@ -51,10 +51,6 @@ Numeric histogram:
}
*/
module.exports = class NumericHistogram extends BaseHistogram {
constructor (query, options, queries) {
super(query, options, queries);
}
_buildQuery (psql, override, callback) {
const histogramSql = this._buildQueryTpl({
column: this._columnType === 'date' ? utils.columnCastTpl({ column: this.column }) : this.column,

View File

@ -9,7 +9,7 @@ var filterQueryTpl = dot.template([
'FROM ({{=it._sql}}) _analysis_category_filter',
'WHERE {{=it._filters}}'
].join('\n'));
var escapeStringTpl = dot.template('$escape_{{=it._i}}${{=it._value}}$escape_{{=it._i}}$');
var escapeStringTpl = dot.template('$escape_{{=it._i}}${{=it._value}}$escape_{{=it._i}}$'); // eslint-disable-line no-template-curly-in-string
var inConditionTpl = dot.template('{{=it._column}} IN ({{=it._values}})');
var notInConditionTpl = dot.template('{{=it._column}} NOT IN ({{=it._values}})');

View File

@ -233,7 +233,7 @@ function appendFiltersToNodes (requestMapConfig, dataviewsFiltersBySourceId) {
}
function shouldAdaptLayers (requestMapConfig) {
return Array.isArray(requestMapConfig.layers) && requestMapConfig.layers.some(getLayerSourceId) ||
return (Array.isArray(requestMapConfig.layers) && requestMapConfig.layers.some(getLayerSourceId)) ||
(Array.isArray(requestMapConfig.analyses) && requestMapConfig.analyses.length > 0) ||
requestMapConfig.dataviews;
}

View File

@ -156,10 +156,6 @@ class Resource {
}
class TileResource extends Resource {
constructor (resourcePath) {
super(resourcePath);
}
getDomain (domain, subdomains) {
if (!subdomains) {
return domain;
@ -179,10 +175,6 @@ class TileResource extends Resource {
}
class TemplateResource extends Resource {
constructor (resourcePath) {
super(resourcePath);
}
getDomain (domain, subdomains) {
return {
urlTemplate: domain,

View File

@ -4,7 +4,7 @@ module.exports = function jsonReplacerFactory () {
// Fix: https://github.com/CartoDB/Windshaft-cartodb/issues/705
// See: http://expressjs.com/en/4x/api.html#app.set
return function jsonReplacer (key, value) {
if (value !== value) {
if (value !== value) { // eslint-disable-line no-self-compare
return 'NaN';
}

View File

@ -559,7 +559,7 @@ describe('cluster', function () {
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));
(a.type === b.type && a.max_value < b.max_value)));
};
assert.deepStrictEqual(body.rows.sort(sort_f), expected.sort(sort_f));

View File

@ -6,7 +6,7 @@ var assert = require('../../support/assert');
var TestClient = require('../../support/test-client');
var moment = require('moment');
function createMapConfig(layers, dataviews, analysis) {
function createMapConfig (layers, dataviews, analysis) {
return {
version: '1.5.0',
layers: layers,
@ -15,18 +15,8 @@ function createMapConfig(layers, dataviews, analysis) {
};
}
function createMapConfig(layers, dataviews, analysis) {
return {
version: '1.5.0',
layers: layers,
dataviews: dataviews || {},
analyses: analysis || []
};
}
describe('histogram-dataview', function() {
afterEach(function(done) {
describe('histogram-dataview', function () {
afterEach(function (done) {
if (this.testClient) {
this.testClient.drain(done);
} else {
@ -37,13 +27,13 @@ describe('histogram-dataview', function() {
var mapConfig = createMapConfig(
[
{
"type": "cartodb",
"options": {
"source": {
"id": "2570e105-7b37-40d2-bdf4-1af889598745"
type: 'cartodb',
options: {
source: {
id: '2570e105-7b37-40d2-bdf4-1af889598745'
},
"cartocss": "#points { marker-width: 10; marker-fill: red; }",
"cartocss_version": "2.3.0"
cartocss: '#points { marker-width: 10; marker-fill: red; }',
cartocss_version: '2.3.0'
}
}
],
@ -60,16 +50,16 @@ describe('histogram-dataview', function() {
},
[
{
"id": "2570e105-7b37-40d2-bdf4-1af889598745",
"type": "source",
"params": {
"query": "select null::geometry the_geom_webmercator, x from generate_series(0,1000) x"
id: '2570e105-7b37-40d2-bdf4-1af889598745',
type: 'source',
params: {
query: 'select null::geometry the_geom_webmercator, x from generate_series(0,1000) x'
}
}
]
);
it('should get bins with min >= start and max <= end', function(done) {
it('should get bins with min >= start and max <= end', function (done) {
var params = {
bins: 3,
start: 50,
@ -77,12 +67,12 @@ describe('histogram-dataview', function() {
};
this.testClient = new TestClient(mapConfig, 1234);
this.testClient.getDataview('pop_max_histogram', params, function(err, dataview) {
this.testClient.getDataview('pop_max_histogram', params, function (err, dataview) {
assert.ok(!err, err);
assert.ok(3 === dataview.bins_count, 'Unexpected bin count: ' + dataview.bins_count);
assert.ok(3 === dataview.bins.length, 'Unexpected number of bins: ' + dataview.bins.length);
dataview.bins.forEach(function(bin) {
assert.ok(dataview.bins_count === 3, 'Unexpected bin count: ' + dataview.bins_count);
assert.ok(dataview.bins.length === 3, 'Unexpected number of bins: ' + dataview.bins.length);
dataview.bins.forEach(function (bin) {
assert.ok(bin.min >= params.start, 'bin min < start: ' + JSON.stringify(bin));
assert.ok(bin.max <= params.end, 'bin max > end: ' + JSON.stringify(bin));
});
@ -90,19 +80,19 @@ describe('histogram-dataview', function() {
});
});
it('should work with min >= start and max <= end, autodetect bins', function(done) {
it('should work with min >= start and max <= end, autodetect bins', function (done) {
var params = {
start: 50,
end: 500
};
this.testClient = new TestClient(mapConfig, 1234);
this.testClient.getDataview('pop_max_histogram', params, function(err, dataview) {
this.testClient.getDataview('pop_max_histogram', params, function (err, dataview) {
assert.ok(!err, err);
assert.ok(6 === dataview.bins_count, 'Unexpected bin count: ' + dataview.bins_count);
assert.ok(6 === dataview.bins.length, 'Unexpected number of bins: ' + dataview.bins.length);
dataview.bins.forEach(function(bin) {
assert.ok(dataview.bins_count === 6, 'Unexpected bin count: ' + dataview.bins_count);
assert.ok(dataview.bins.length === 6, 'Unexpected number of bins: ' + dataview.bins.length);
dataview.bins.forEach(function (bin) {
assert.ok(bin.min >= params.start, 'bin min < start: ' + JSON.stringify(bin));
assert.ok(bin.max <= params.end, 'bin max > end: ' + JSON.stringify(bin));
});
@ -110,7 +100,7 @@ describe('histogram-dataview', function() {
});
});
it('should get bin_width right when max > min in filter', function(done) {
it('should get bin_width right when max > min in filter', function (done) {
var params = {
bins: 10,
start: 1e3,
@ -118,12 +108,12 @@ describe('histogram-dataview', function() {
};
this.testClient = new TestClient(mapConfig, 1234);
this.testClient.getDataview('pop_max_histogram', params, function(err, dataview) {
this.testClient.getDataview('pop_max_histogram', params, function (err, dataview) {
assert.ok(!err, err);
assert.strictEqual(dataview.type, 'histogram');
assert.ok(dataview.bin_width > 0, 'Unexpected bin width: ' + dataview.bin_width);
dataview.bins.forEach(function(bin) {
dataview.bins.forEach(function (bin) {
assert.ok(bin.min <= bin.max, 'bin min < bin max: ' + JSON.stringify(bin));
});
@ -131,7 +121,7 @@ describe('histogram-dataview', function() {
});
});
it('should cast all overridable params to numbers', function(done) {
it('should cast all overridable params to numbers', function (done) {
var params = {
bins: '256 AS other, (select 256 * 2) AS bins_number--',
start: 1e3,
@ -140,7 +130,7 @@ describe('histogram-dataview', function() {
};
this.testClient = new TestClient(mapConfig, 1234);
this.testClient.getDataview('pop_max_histogram', params, function(err, res) {
this.testClient.getDataview('pop_max_histogram', params, function (err, res) {
assert.ok(!err, err);
assert.ok(res.errors);
assert.strictEqual(res.errors.length, 1);
@ -149,11 +139,10 @@ describe('histogram-dataview', function() {
done();
});
});
});
describe('histogram-dataview for date column type', function() {
afterEach(function(done) {
describe('histogram-dataview for date column type', function () {
afterEach(function (done) {
if (this.testClient) {
this.testClient.drain(done);
} else {
@ -164,13 +153,13 @@ describe('histogram-dataview for date column type', function() {
var mapConfig = createMapConfig(
[
{
"type": "cartodb",
"options": {
"source": {
"id": "datetime-histogram-source-week"
type: 'cartodb',
options: {
source: {
id: 'datetime-histogram-source-week'
},
"cartocss": "#points { marker-width: 10; marker-fill: red; }",
"cartocss_version": "2.3.0"
cartocss: '#points { marker-width: 10; marker-fill: red; }',
cartocss_version: '2.3.0'
}
}
],
@ -340,181 +329,181 @@ describe('histogram-dataview for date column type', function() {
},
[
{
"id": "datetime-histogram-source-second",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date AS d",
"from generate_series(",
"'2007-02-15 01:00:00'::timestamp, '2007-02-15 01:00:57'::timestamp,",
"'0.9 second'::interval",
") date"
id: 'datetime-histogram-source-second',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
"'2007-02-15 01:00:00'::timestamp, '2007-02-15 01:00:57'::timestamp,",
"'0.9 second'::interval",
') date'
].join(' ')
}
},
{
"id": "datetime-histogram-source-minute",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date AS d",
"from generate_series(",
"'2007-02-15 01:00:00'::timestamp, '2007-02-15 02:00:57'::timestamp,",
"'75 second'::interval",
") date"
id: 'datetime-histogram-source-minute',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
"'2007-02-15 01:00:00'::timestamp, '2007-02-15 02:00:57'::timestamp,",
"'75 second'::interval",
') date'
].join(' ')
}
},
{
"id": "datetime-histogram-source-hour",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date AS d",
"from generate_series(",
"'2007-02-15 01:00:00'::timestamp, '2007-02-18 02:00:57'::timestamp,",
"'47 minutes'::interval",
") date"
id: 'datetime-histogram-source-hour',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
"'2007-02-15 01:00:00'::timestamp, '2007-02-18 02:00:57'::timestamp,",
"'47 minutes'::interval",
') date'
].join(' ')
}
},
{
"id": "datetime-histogram-source-day",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date AS d",
"from generate_series(",
"'2007-02-15 01:00:00'::timestamp, '2007-04-18 02:00:57'::timestamp,",
"'24 hours'::interval",
") date"
id: 'datetime-histogram-source-day',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
"'2007-02-15 01:00:00'::timestamp, '2007-04-18 02:00:57'::timestamp,",
"'24 hours'::interval",
') date'
].join(' ')
}
},
{
"id": "datetime-histogram-source-week",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date AS d",
"from generate_series(",
"'2007-02-15 01:00:00'::timestamp, '2008-04-09 01:00:00'::timestamp,",
"'1 day'::interval",
") date"
id: 'datetime-histogram-source-week',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
"'2007-02-15 01:00:00'::timestamp, '2008-04-09 01:00:00'::timestamp,",
"'1 day'::interval",
') date'
].join(' ')
}
},
{
"id": "datetime-histogram-source-month",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date AS d",
"from generate_series(",
"'2007-02-15 01:00:00'::timestamp, '2010-04-09 01:00:00'::timestamp,",
"'30 day'::interval",
") date"
id: 'datetime-histogram-source-month',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
"'2007-02-15 01:00:00'::timestamp, '2010-04-09 01:00:00'::timestamp,",
"'30 day'::interval",
') date'
].join(' ')
}
},
{
"id": "datetime-histogram-source-quarter",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date AS d",
"from generate_series(",
"'2007-02-15 01:00:00'::timestamp, '2020-04-09 01:00:00'::timestamp,",
"'30 day'::interval",
") date"
id: 'datetime-histogram-source-quarter',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
"'2007-02-15 01:00:00'::timestamp, '2020-04-09 01:00:00'::timestamp,",
"'30 day'::interval",
') date'
].join(' ')
}
},
{
"id": "datetime-histogram-source-year",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date AS d",
"from generate_series(",
"'1990-02-15 01:00:00'::timestamp, '2018-04-09 01:00:00'::timestamp,",
"'30 day'::interval",
") date"
id: 'datetime-histogram-source-year',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
"'1990-02-15 01:00:00'::timestamp, '2018-04-09 01:00:00'::timestamp,",
"'30 day'::interval",
') date'
].join(' ')
}
},
{
"id": "datetime-histogram-source-decade",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date AS d",
"from generate_series(",
"'1850-02-15 01:00:00'::timestamp, '2018-04-09 01:00:00'::timestamp,",
"'30 day'::interval",
") date"
id: 'datetime-histogram-source-decade',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
"'1850-02-15 01:00:00'::timestamp, '2018-04-09 01:00:00'::timestamp,",
"'30 day'::interval",
') date'
].join(' ')
}
},
{
"id": "datetime-histogram-source-century",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date AS d",
"from generate_series(",
"'0650-02-15 01:00:00'::timestamp, '1918-04-09 01:00:00'::timestamp,",
"'6 years'::interval",
") date"
id: 'datetime-histogram-source-century',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
"'0650-02-15 01:00:00'::timestamp, '1918-04-09 01:00:00'::timestamp,",
"'6 years'::interval",
') date'
].join(' ')
}
},
{
"id": "datetime-histogram-source-millennium",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date AS d",
"from generate_series(",
"'0005-02-15 01:00:00'::timestamp, '12000-04-09 01:00:00'::timestamp,",
"'72 years'::interval",
") date"
id: 'datetime-histogram-source-millennium',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
"'0005-02-15 01:00:00'::timestamp, '12000-04-09 01:00:00'::timestamp,",
"'72 years'::interval",
') date'
].join(' ')
}
},
{
"id": "datetime-histogram-source-tz",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date AS d",
id: 'datetime-histogram-source-tz',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date AS d',
"from generate_series('2007-02-15 01:00:00+00'::timestamptz,",
"'2008-04-09 01:00:00+00'::timestamptz, '1 day'::interval",
") date"
') date'
].join(' ')
}
},
{
"id": "date-histogram-source",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date::date AS d",
"from generate_series(",
"'2007-02-15'::date, '2008-04-09'::date, '1 day'::interval",
") date"
id: 'date-histogram-source',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date::date AS d',
'from generate_series(',
"'2007-02-15'::date, '2008-04-09'::date, '1 day'::interval",
') date'
].join(' ')
}
},
{
"id": "minute-histogram-source-tz",
"type": "source",
"params": {
"query": [
"select null::geometry the_geom_webmercator, date AS d",
id: 'minute-histogram-source-tz',
type: 'source',
params: {
query: [
'select null::geometry the_geom_webmercator, date AS d',
"from generate_series('2007-02-15 23:50:00+00'::timestamptz,",
"'2007-02-16 00:10:00+00'::timestamptz, '1 minute'::interval",
") date"
') date'
].join(' ')
}
}
@ -530,13 +519,12 @@ describe('histogram-dataview for date column type', function() {
}];
dateHistogramsUseCases.forEach(function (test) {
it('should create a date histogram aggregated in months (EDT) ' + test.desc, function (done) {
var OFFSET_EDT_IN_MINUTES = -4 * 60; // EDT Eastern Daylight Time (GMT-4) in minutes
this.testClient = new TestClient(mapConfig, 1234);
this.testClient.getDataview(test.dataviewId, {}, function(err, dataview) {
this.testClient.getDataview(test.dataviewId, {}, function (err, dataview) {
assert.ok(!err, err);
assert.strictEqual(dataview.type, 'histogram');
assert.ok(dataview.bin_width > 0, 'Unexpected bin width: ' + dataview.bin_width);
@ -549,7 +537,7 @@ describe('histogram-dataview for date column type', function() {
.format();
assert.strictEqual(binsStartFormatted, initialTimestamp);
dataview.bins.forEach(function(bin, index) {
dataview.bins.forEach(function (bin, index) {
var binTimestampExpected = moment.utc(initialTimestamp)
.utcOffset(OFFSET_EDT_IN_MINUTES)
.add(index, 'month')
@ -908,9 +896,6 @@ describe('histogram-dataview for date column type', function() {
});
});
it('bins_count should be equal to bins length filtered by start and end ' + test.desc, function (done) {
var OFFSET_UTC_IN_SECONDS = 0 * 3600; // UTC
var params = {
@ -1095,8 +1080,6 @@ describe('histogram-dataview for date column type', function() {
});
});
it('should work with dates', function (done) {
var params = {};
this.testClient = new TestClient(mapConfig, 1234);
@ -1110,7 +1093,6 @@ describe('histogram-dataview for date column type', function() {
});
});
it('should not apply offset for a histogram aggregated by minutes', function (done) {
var self = this;
var params = {
@ -1155,23 +1137,22 @@ describe('histogram-dataview for date column type', function() {
assert.deepStrictEqual(dataview, filteredDataview);
self.testClient.getDataview('minute_histogram', paramsWithOffset,
function (err, filteredWithOffsetDataview) {
assert.ifError(err);
function (err, filteredWithOffsetDataview) {
assert.ifError(err);
assert.notStrictEqual(filteredWithOffsetDataview.offset, filteredDataview.offset);
filteredWithOffsetDataview.offset = filteredDataview.offset;
assert.deepStrictEqual(filteredWithOffsetDataview, filteredDataview);
done();
});
assert.notStrictEqual(filteredWithOffsetDataview.offset, filteredDataview.offset);
filteredWithOffsetDataview.offset = filteredDataview.offset;
assert.deepStrictEqual(filteredWithOffsetDataview, filteredDataview);
done();
});
});
});
});
it('should return an histogram aggregated by days', function (done) {
var self = this;
var paramsWithDailyAgg = {
aggregation: 'day',
aggregation: 'day'
};
// data: from 2007-02-15 23:50:00 to 2007-02-16 00:10:00
@ -1253,10 +1234,8 @@ describe('histogram-dataview for date column type', function() {
});
});
describe('histogram-dataview: special float valuer', function() {
afterEach(function(done) {
describe('histogram-dataview: special float valuer', function () {
afterEach(function (done) {
if (this.testClient) {
this.testClient.drain(done);
} else {
@ -1267,13 +1246,13 @@ describe('histogram-dataview: special float valuer', function() {
var mapConfig = createMapConfig(
[
{
"type": "cartodb",
"options": {
"source": {
"id": "a0"
type: 'cartodb',
options: {
source: {
id: 'a0'
},
"cartocss": "#points { marker-width: 10; marker-fill: red; }",
"cartocss_version": "2.3.0"
cartocss: '#points { marker-width: 10; marker-fill: red; }',
cartocss_version: '2.3.0'
}
}
],
@ -1290,10 +1269,10 @@ describe('histogram-dataview: special float valuer', function() {
},
[
{
"id": "a0",
"type": "source",
"params": {
"query": [
id: 'a0',
type: 'source',
params: {
query: [
'SELECT',
' null::geometry the_geom_webmercator,',
' CASE',
@ -1309,9 +1288,9 @@ describe('histogram-dataview: special float valuer', function() {
]
);
it('should filter infinities out and count them in the summary', function(done) {
it('should filter infinities out and count them in the summary', function (done) {
this.testClient = new TestClient(mapConfig, 1234);
this.testClient.getDataview('val_histogram', {}, function(err, dataview) {
this.testClient.getDataview('val_histogram', {}, function (err, dataview) {
assert.ok(!err, err);
assert.ok(dataview.infinities === (250 + 250));
assert.ok(dataview.nans === 250);
@ -1320,9 +1299,8 @@ describe('histogram-dataview: special float valuer', function() {
});
});
describe('histogram-dates: aggregation input value', function() {
afterEach(function(done) {
describe('histogram-dates: aggregation input value', function () {
afterEach(function (done) {
if (this.testClient) {
this.testClient.drain(done);
} else {
@ -1333,13 +1311,13 @@ describe('histogram-dates: aggregation input value', function() {
var mapConfig = createMapConfig(
[
{
type: "cartodb",
type: 'cartodb',
options: {
source: {
id: "a0"
id: 'a0'
},
cartocss: "#points { marker-width: 10; marker-fill: red; }",
cartocss_version: "2.3.0"
cartocss: '#points { marker-width: 10; marker-fill: red; }',
cartocss_version: '2.3.0'
}
}
],
@ -1373,9 +1351,9 @@ describe('histogram-dates: aggregation input value', function() {
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
'\'2007-02-15 01:00:00\'::timestamp,',
'\'2008-04-09 01:00:00\'::timestamp,',
' \'1 day\'::interval',
'\'2007-02-15 01:00:00\'::timestamp,',
'\'2008-04-09 01:00:00\'::timestamp,',
' \'1 day\'::interval',
') date'
].join(' ')
}
@ -1383,7 +1361,7 @@ describe('histogram-dates: aggregation input value', function() {
]
);
it('should fail when aggregation values is not valid while instantiating the map', function(done) {
it('should fail when aggregation values is not valid while instantiating the map', function (done) {
this.testClient = new TestClient(mapConfig, 1234);
const override = {
response: {
@ -1391,7 +1369,7 @@ describe('histogram-dates: aggregation input value', function() {
}
};
this.testClient.getDataview('bad_agg_value_histogram', override, function(err, dataviewError) {
this.testClient.getDataview('bad_agg_value_histogram', override, function (err, dataviewError) {
assert.ifError(err);
assert.deepStrictEqual(dataviewError, {
@ -1413,7 +1391,7 @@ describe('histogram-dates: aggregation input value', function() {
});
});
it('should fail when aggregation values is not valid while fetching dataview result', function(done) {
it('should fail when aggregation values is not valid while fetching dataview result', function (done) {
this.testClient = new TestClient(mapConfig, 1234);
const override = {
aggregation: 'wadus',
@ -1422,7 +1400,7 @@ describe('histogram-dates: aggregation input value', function() {
}
};
this.testClient.getDataview('agg_value_histogram', override, function(err, dataviewError) {
this.testClient.getDataview('agg_value_histogram', override, function (err, dataviewError) {
assert.ifError(err);
assert.deepStrictEqual(dataviewError, {
@ -1445,9 +1423,8 @@ describe('histogram-dates: aggregation input value', function() {
});
});
describe('histogram-dates: timestamp starts at epoch', function() {
afterEach(function(done) {
describe('histogram-dates: timestamp starts at epoch', function () {
afterEach(function (done) {
if (this.testClient) {
this.testClient.drain(done);
} else {
@ -1458,13 +1435,13 @@ describe('histogram-dates: timestamp starts at epoch', function() {
var mapConfig = createMapConfig(
[
{
type: "cartodb",
type: 'cartodb',
options: {
source: {
id: "a0"
id: 'a0'
},
cartocss: "#points { marker-width: 10; marker-fill: red; }",
cartocss_version: "2.3.0"
cartocss: '#points { marker-width: 10; marker-fill: red; }',
cartocss_version: '2.3.0'
}
}
],
@ -1488,9 +1465,9 @@ describe('histogram-dates: timestamp starts at epoch', function() {
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
'\'1970-01-04 10:00:00\'::timestamp,',
'\'1984-01-04 10:00:00\'::timestamp,',
' \'1 month\'::interval',
'\'1970-01-04 10:00:00\'::timestamp,',
'\'1984-01-04 10:00:00\'::timestamp,',
' \'1 month\'::interval',
') date'
].join(' ')
}
@ -1498,11 +1475,11 @@ describe('histogram-dates: timestamp starts at epoch', function() {
]
);
it('should work when timestamp_start is epoch (1970-01-01 = 0)', function(done) {
it('should work when timestamp_start is epoch (1970-01-01 = 0)', function (done) {
this.testClient = new TestClient(mapConfig, 1234);
const override = {};
this.testClient.getDataview('epoch_start_histogram', override, function(err, dataview) {
this.testClient.getDataview('epoch_start_histogram', override, function (err, dataview) {
assert.ifError(err);
const { aggregation, timestamp_start } = dataview;
@ -1515,9 +1492,8 @@ describe('histogram-dates: timestamp starts at epoch', function() {
});
});
describe('histogram-dates: trunc timestamp for each bin respecting user\'s timezone', function() {
afterEach(function(done) {
describe('histogram-dates: trunc timestamp for each bin respecting user\'s timezone', function () {
afterEach(function (done) {
if (this.testClient) {
this.testClient.drain(done);
} else {
@ -1528,13 +1504,13 @@ describe('histogram-dates: trunc timestamp for each bin respecting user\'s timez
var mapConfig = createMapConfig(
[
{
type: "cartodb",
type: 'cartodb',
options: {
source: {
id: "a0"
id: 'a0'
},
cartocss: "#points { marker-width: 10; marker-fill: red; }",
cartocss_version: "2.3.0"
cartocss: '#points { marker-width: 10; marker-fill: red; }',
cartocss_version: '2.3.0'
}
}
],
@ -1568,9 +1544,9 @@ describe('histogram-dates: trunc timestamp for each bin respecting user\'s timez
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
'\'1970-01-01 00:00:00\'::timestamp,',
'\'1970-01-01 01:59:00\'::timestamp,',
' \'1 minute\'::interval',
'\'1970-01-01 00:00:00\'::timestamp,',
'\'1970-01-01 01:59:00\'::timestamp,',
' \'1 minute\'::interval',
') date'
].join(' ')
}
@ -1582,9 +1558,9 @@ describe('histogram-dates: trunc timestamp for each bin respecting user\'s timez
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
'\'1970-01-01 00:00:00\'::timestamptz,',
'\'1970-01-01 01:59:00\'::timestamptz,',
' \'1 minute\'::interval',
'\'1970-01-01 00:00:00\'::timestamptz,',
'\'1970-01-01 01:59:00\'::timestamptz,',
' \'1 minute\'::interval',
') date'
].join(' ')
}
@ -1601,7 +1577,7 @@ describe('histogram-dates: trunc timestamp for each bin respecting user\'s timez
}];
dateHistogramsUseCases.forEach(function (test) {
it('should return histogram with two buckets ' + test.desc , function(done) {
it('should return histogram with two buckets ' + test.desc, function (done) {
this.testClient = new TestClient(mapConfig, 1234);
const override = {
@ -1609,7 +1585,7 @@ describe('histogram-dates: trunc timestamp for each bin respecting user\'s timez
offset: '-3600'
};
this.testClient.getDataview(test.dataviewId, override, function(err, dataview) {
this.testClient.getDataview(test.dataviewId, override, function (err, dataview) {
assert.ifError(err);
var OFFSET_IN_MINUTES = -1 * 60; // GMT-01
@ -1641,10 +1617,8 @@ describe('histogram-dates: trunc timestamp for each bin respecting user\'s timez
});
});
describe('histogram: be able to override with aggregation for histograms instantiated w/o aggregation', function() {
afterEach(function(done) {
describe('histogram: be able to override with aggregation for histograms instantiated w/o aggregation', function () {
afterEach(function (done) {
if (this.testClient) {
this.testClient.drain(done);
} else {
@ -1655,13 +1629,13 @@ describe('histogram: be able to override with aggregation for histograms instant
var mapConfig = createMapConfig(
[
{
type: "cartodb",
type: 'cartodb',
options: {
source: {
id: "a0"
id: 'a0'
},
cartocss: "#points { marker-width: 10; marker-fill: red; }",
cartocss_version: "2.3.0"
cartocss: '#points { marker-width: 10; marker-fill: red; }',
cartocss_version: '2.3.0'
}
}
],
@ -1672,7 +1646,7 @@ describe('histogram: be able to override with aggregation for histograms instant
},
type: 'histogram',
options: {
column: 'd',
column: 'd'
}
}
},
@ -1684,9 +1658,9 @@ describe('histogram: be able to override with aggregation for histograms instant
query: [
'select null::geometry the_geom_webmercator, date AS d',
'from generate_series(',
'\'1970-01-01 00:00:00\'::timestamp,',
'\'1970-01-01 01:59:00\'::timestamp,',
' \'1 minute\'::interval',
'\'1970-01-01 00:00:00\'::timestamp,',
'\'1970-01-01 01:59:00\'::timestamp,',
' \'1 minute\'::interval',
') date'
].join(' ')
}
@ -1694,7 +1668,7 @@ describe('histogram: be able to override with aggregation for histograms instant
]
);
it('should apply aggregation to the histogram', function(done) {
it('should apply aggregation to the histogram', function (done) {
this.testClient = new TestClient(mapConfig, 1234);
const override = {
@ -1702,7 +1676,7 @@ describe('histogram: be able to override with aggregation for histograms instant
offset: '-3600'
};
this.testClient.getDataview('timezone_epoch_histogram', override, function(err, dataview) {
this.testClient.getDataview('timezone_epoch_histogram', override, function (err, dataview) {
assert.ifError(err);
var OFFSET_IN_MINUTES = -1 * 60; // GMT-01

View File

@ -78,7 +78,7 @@ describe('named maps provider cache', function () {
assert.response(server, requestOptions, expectedResponse, function (res, err) {
var img;
if (res.statusCode === 200) {
img = mapnik.Image.fromBytes(new Buffer.from(res.body, 'binary'));
img = mapnik.Image.fromBytes(Buffer.from(res.body, 'binary'));
}
return callback(err, res, img);
});

View File

@ -91,7 +91,7 @@ describe('retina support', function () {
function (res, err) {
assert.ok(!err, 'Failed to request 0/0/0' + scaleFactor + '.png tile');
var image = new mapnik.Image.fromBytes(Buffer.from(res.body, 'binary'));
var image = mapnik.Image.fromBytes(Buffer.from(res.body, 'binary'));
assert.strictEqual(image.width(), imageSize);
assert.strictEqual(image.height(), imageSize);

View File

@ -91,9 +91,7 @@ function createLayergroup (layergroupConfig, options, callback) {
global[options.callbackName] = function (layergroup) {
layergroupid = layergroup.layergroupid;
};
// jshint ignore:start
eval(res.body);
// jshint ignore:end
eval(res.body); // eslint-disable-line no-eval
delete global[options.callbackName];
} else {
parsedBody = JSON.parse(res.body);
@ -404,7 +402,7 @@ function getGeneric (layergroupConfig, url, expectedResponse, callback) {
var img;
if (contentType === pngContentType) {
img = new mapnik.Image.fromBytesSync(Buffer.from(res.body, 'binary'));
img = mapnik.Image.fromBytesSync(Buffer.from(res.body, 'binary'));
}
var keysToDelete = {