diff --git a/lib/classes/datasource.js b/lib/classes/datasource.js index 0da07e62d66b7..9789d63787ab3 100644 --- a/lib/classes/datasource.js +++ b/lib/classes/datasource.js @@ -52,6 +52,7 @@ module.exports = class Datasource extends TimelionFunction { if (args.byName.offset) { config.time = _.cloneDeep(tlConfig.time); config.time.from = offsetTime(config.time.from, args.byName.offset); + config.time.to = offsetTime(config.time.to, args.byName.offset); } return originalFunction(args, config).then(function (seriesList) { @@ -79,6 +80,10 @@ module.exports = class Datasource extends TimelionFunction { } super(name, config); + + // You need to call _fn if calling up a datasource from another datasource, + // otherwise teh series will end up being fit and offset twice. + this._fn = originalFunction; this.datasource = true; this.cacheKey = function (item) { return item.text; diff --git a/package.json b/package.json index 9c21f865390c8..e64e62d3dc51f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "timelion", - "version": "0.1.3", + "version": "0.1.4", "dependencies": { "body-parser": "^1.12.0", "boom": "^2.8.0", diff --git a/series_functions/worldbank_indicators.js b/series_functions/worldbank_indicators.js index c8fe81437de94..7ad35fe2545a4 100644 --- a/series_functions/worldbank_indicators.js +++ b/series_functions/worldbank_indicators.js @@ -30,7 +30,7 @@ module.exports = new Datasource ('worldbank_indicators', { var code = 'countries/' + country + '/indicators/' + config.indicator; var wbArgs = [code]; wbArgs.byName = {code: code}; - return worldbank.fn(wbArgs, tlConfig); + return worldbank._fn(wbArgs, tlConfig); }); return Promise.map(seriesLists, function (seriesList) {