From 347dea8f6656f2429a9c4f456f0c44b30fedc57f Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 8 Sep 2017 12:01:15 +0200 Subject: [PATCH] naming private functions --- lib/cartodb/models/dataview/date-histogram.js | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/cartodb/models/dataview/date-histogram.js b/lib/cartodb/models/dataview/date-histogram.js index f7d11c67..efd3f4be 100644 --- a/lib/cartodb/models/dataview/date-histogram.js +++ b/lib/cartodb/models/dataview/date-histogram.js @@ -208,17 +208,17 @@ module.exports = class DateHistogram extends BaseDataview { return null; } - if (this.isDateHistogram(override)) { + if (this._isDateHistogram(override)) { return this._buildQuery(psql, override, callback); } } - isDateHistogram (override) { + _isDateHistogram (override) { return this._columnType === 'date' && (this.aggregation !== undefined || override.aggregation !== undefined); } - buildDateHistogramQueryTpl (ctx) { + _buildDateHistogramQueryTpl (ctx) { return ` WITH ${ctx._override && ctx._override.hasOwnProperty('start') && ctx._override.hasOwnProperty('end') ? @@ -241,7 +241,7 @@ module.exports = class DateHistogram extends BaseDataview { } if (_aggregation === 'auto') { - this.getAutomaticAggregation(psql, function (err, aggregation) { + this._getAutomaticAggregation(psql, function (err, aggregation) { if (err || aggregation === 'none') { this.aggregation = 'day'; } else { @@ -253,14 +253,14 @@ module.exports = class DateHistogram extends BaseDataview { return null; } - const histogramSql = this.buildDateHistogramQueryTpl({ + const histogramSql = this._buildDateHistogramQueryTpl({ _override: override, _query: this.query, _column: this.column, _aggregation: _aggregation, - _start: this.getBinStart(override), - _end: this.getBinEnd(override), - _offset: this.parseOffset(_offset, _aggregation) + _start: this._getBinStart(override), + _end: this._getBinEnd(override), + _offset: this._parseOffset(_offset, _aggregation) }); debug(histogramSql); @@ -268,7 +268,7 @@ module.exports = class DateHistogram extends BaseDataview { return callback(null, histogramSql); } - getAutomaticAggregation (psql, callback) { + _getAutomaticAggregation (psql, callback) { var dateIntervalQuery = dateIntervalQueryTpl({ query: this.query, column: this.column @@ -312,9 +312,9 @@ module.exports = class DateHistogram extends BaseDataview { override = override || {}; var buckets = []; - var binsCount = this.getBinsCount(override); - var width = this.getWidth(override); - var binsStart = this.getBinStart(override); + var binsCount = this._getBinsCount(override); + var width = this._getWidth(override); + var binsStart = this._getBinStart(override); var nulls = 0; var infinities = 0; var nans = 0; @@ -332,11 +332,11 @@ module.exports = class DateHistogram extends BaseDataview { timestampStart = firstRow.timestamp_start; infinities = firstRow.infinities_count; nans = firstRow.nans_count; - binsStart = this.populateBinStart(override, firstRow); + binsStart = this._populateBinStart(override, firstRow); if (Number.isFinite(timestampStart)) { - aggregation = this.getAggregation(override); - offset = this.getOffset(override); + aggregation = this._getAggregation(override); + offset = this._getOffset(override); } buckets = result.rows.map(row => ({ bin, min, max, avg, freq, timestamp } = row)); @@ -357,11 +357,11 @@ module.exports = class DateHistogram extends BaseDataview { }; } - getType () { + _getType () { return TYPE; } - toString () { + _toString () { return JSON.stringify({ _type: TYPE, _column: this.column, @@ -369,11 +369,11 @@ module.exports = class DateHistogram extends BaseDataview { }); } - getAggregation (override) { + _getAggregation (override) { return override && override.aggregation ? override.aggregation : this.aggregation; } - getOffset (override) { + _getOffset (override) { if (override && override.offset) { return override.offset; } @@ -384,20 +384,20 @@ module.exports = class DateHistogram extends BaseDataview { return 0; } - getBinStart (override) { + _getBinStart (override) { if (override.hasOwnProperty('start') && override.hasOwnProperty('end')) { return Math.min(override.start, override.end); } return override.start || 0; } - populateBinStart (override, firstRow) { + _populateBinStart (override, firstRow) { var binStart; if (firstRow.hasOwnProperty('timestamp')) { binStart = firstRow.timestamp; } else if (override.hasOwnProperty('start')) { - binStart = this.getBinStart(override); + binStart = this._getBinStart(override); } else { binStart = firstRow.min; } @@ -405,18 +405,18 @@ module.exports = class DateHistogram extends BaseDataview { return binStart; } - getBinEnd (override) { + _getBinEnd (override) { if (override.hasOwnProperty('start') && override.hasOwnProperty('end')) { return Math.max(override.start, override.end); } return override.end || 0; } - getBinsCount (override) { + _getBinsCount (override) { return override.bins || 0; } - getWidth (override) { + _getWidth (override) { var width = 0; var binsCount = override.bins; @@ -427,7 +427,7 @@ module.exports = class DateHistogram extends BaseDataview { return width; } - parseOffset (offset, aggregation) { + _parseOffset (offset, aggregation) { if (!offset) { return '0'; }