diff --git a/lib/cartodb/models/dataview/histogram.js b/lib/cartodb/models/dataview/histogram.js index 3e9868d9..9ab349df 100644 --- a/lib/cartodb/models/dataview/histogram.js +++ b/lib/cartodb/models/dataview/histogram.js @@ -495,14 +495,14 @@ module.exports = class Histogram extends BaseWidget { _aggregation: _aggregation, _start: this.getBinStart(override), _end: this.getBinEnd(override), - _offset: parseOffset(_offset, _aggregation) + _offset: this.parseOffset(_offset, _aggregation) }); } else { dateBasicsQuery = dateBasicsQueryTpl({ _query: _query, _column: _column, _aggregation: _aggregation, - _offset: parseOffset(_offset, _aggregation) + _offset: this.parseOffset(_offset, _aggregation) }); } @@ -521,7 +521,7 @@ module.exports = class Histogram extends BaseWidget { _query: _query, _column: _column, _aggregation: _aggregation, - _offset: parseOffset(_offset, _aggregation) + _offset: this.parseOffset(_offset, _aggregation) }); var histogramSql = [ @@ -708,6 +708,18 @@ module.exports = class Histogram extends BaseWidget { return width; } + + parseOffset (offset, aggregation) { + if (!offset) { + return '0'; + } + if (aggregation === 'hour' || aggregation === 'minute') { + return '0'; + } + + var offsetInHours = Math.ceil(offset / 3600); + return '' + offsetInHours; + } }; var DATE_AGGREGATIONS = { @@ -720,17 +732,3 @@ var DATE_AGGREGATIONS = { 'quarter': true, 'year': true }; - - -function parseOffset(offset, aggregation) { - if (!offset) { - return '0'; - } - if (aggregation === 'hour' || aggregation === 'minute') { - return '0'; - } - - var offsetInHours = Math.ceil(offset / 3600); - return '' + offsetInHours; -} -