Skip to content

Commit

Permalink
provide unwrapped function when needed, closes elastic#11
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashid Khan committed Nov 7, 2015
1 parent 0c3194d commit 40d776d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/classes/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "timelion",
"version": "0.1.3",
"version": "0.1.4",
"dependencies": {
"body-parser": "^1.12.0",
"boom": "^2.8.0",
Expand Down
2 changes: 1 addition & 1 deletion series_functions/worldbank_indicators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 40d776d

Please sign in to comment.