From 288656301bd4b853e53521a6cda493ab985b01fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Wed, 6 Sep 2017 13:53:48 +0200 Subject: [PATCH] Move getOffset function to a class method --- lib/cartodb/models/dataview/histogram.js | 25 ++++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/cartodb/models/dataview/histogram.js b/lib/cartodb/models/dataview/histogram.js index dbe8f014..0e6279b8 100644 --- a/lib/cartodb/models/dataview/histogram.js +++ b/lib/cartodb/models/dataview/histogram.js @@ -607,7 +607,7 @@ module.exports = class Histogram extends BaseWidget { if (Number.isFinite(timestampStart)) { aggregation = this.getAggregation(override); - offset = getOffset(override, this.offset); + offset = this.getOffset(override); } buckets = result.rows.map(function(row) { @@ -654,6 +654,17 @@ module.exports = class Histogram extends BaseWidget { getAggregation (override) { return override && override.aggregation ? override.aggregation : this.aggregation; } + + getOffset (override) { + if (override && override.offset) { + return override.offset; + } + if (this.offset) { + return this.offset; + } + + return 0; + } }; var DATE_AGGREGATIONS = { @@ -667,18 +678,6 @@ var DATE_AGGREGATIONS = { 'year': true }; - -function getOffset(override, offset) { - if (override && override.offset) { - return override.offset; - } - if (offset) { - return offset; - } - - return 0; -} - function getBinStart(override) { if (override.hasOwnProperty('start') && override.hasOwnProperty('end')) { return Math.min(override.start, override.end);