Use ES6 let & const to declare variables

This commit is contained in:
Daniel García Aubert 2017-09-14 16:08:12 +02:00
parent 46254eaf74
commit cd13107a4d

View File

@ -179,8 +179,8 @@ module.exports = class Aggregation extends BaseDataview {
throw new Error(`Aggregation does not support '${options.aggregation}' operation`);
}
var requiredOptions = VALID_OPERATIONS[options.aggregation];
var missingOptions = requiredOptions.filter(requiredOption => !options.hasOwnProperty(requiredOption));
const requiredOptions = VALID_OPERATIONS[options.aggregation];
const missingOptions = requiredOptions.filter(requiredOption => !options.hasOwnProperty(requiredOption));
if (missingOptions.length > 0) {
throw new Error(
@ -197,7 +197,7 @@ module.exports = class Aggregation extends BaseDataview {
}
sql (psql, override, callback) {
var self = this;
const self = this;
if (!callback) {
callback = override;
@ -215,7 +215,7 @@ module.exports = class Aggregation extends BaseDataview {
return null;
}
var aggregationSql = aggregationDataviewQueryTpl({
const aggregationSql = aggregationDataviewQueryTpl({
override: override,
query: this.query,
column: this.column,
@ -235,17 +235,17 @@ module.exports = class Aggregation extends BaseDataview {
}
format (result) {
var categories = [];
var count = 0;
var nulls = 0;
var nans = 0;
var infinities = 0;
var minValue = 0;
var maxValue = 0;
var categoriesCount = 0;
let categories = [];
let count = 0;
let nulls = 0;
let nans = 0;
let infinities = 0;
let minValue = 0;
let maxValue = 0;
let categoriesCount = 0;
if (result.rows.length) {
var firstRow = result.rows[0];
const firstRow = result.rows[0];
count = firstRow.count;
nulls = firstRow.nulls_count;
nans = firstRow.nans_count;
@ -270,14 +270,14 @@ module.exports = class Aggregation extends BaseDataview {
}
search (psql, userQuery, callback) {
var self = this;
const self = this;
var escapedUserQuery = psql.escapeLiteral('%' + userQuery + '%');
var value = this.aggregation !== 'count' && this.aggregationColumn ?
const escapedUserQuery = psql.escapeLiteral('%' + userQuery + '%');
const value = this.aggregation !== 'count' && this.aggregationColumn ?
this.aggregation + '(' + this.aggregationColumn + ')' : 'count(1)';
// TODO unfiltered will be wrong as filters are already applied at this point
var query = searchQueryTpl({
const query = searchQueryTpl({
searchUnfiltered: filterCategoriesQueryTpl({
query: this.query,
column: this.column,