Skip to content

Commit

Permalink
Merge pull request #147 from GoshPosh/pm_fix_timeshift_and_moving_ave…
Browse files Browse the repository at this point in the history
…rage

PM fix timeshift and moving average
  • Loading branch information
ShilpaSivanesan authored Mar 8, 2022
2 parents 52153ee + a973a2e commit fecbe8a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
19 changes: 15 additions & 4 deletions dist/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ function (angular, _, dateMath, moment) {
var targetsByRefId = {};
var sets;

if (typeof (options.targets[0].datasource) === 'object') {
if (typeof (options.targets[0].datasource) === 'object') {
sets = _.groupBy(options.targets, target => target.datasource.uid);
} else {
sets = _.groupBy(options.targets, 'datasource');
}

_.forEach(sets, function (targets, dsName) {
// Grafana (8.x.x) sends datasource name as undefined with mixed plugin made as default datasource
// https://github.com/grafana/grafana/issues/36508
Expand Down Expand Up @@ -229,7 +228,13 @@ function (angular, _, dateMath, moment) {
return timeshift(options.targets[0], options, targetsByRefId, datasourceSrv, metaTarget.outputMetricName)
}
else{
return ds.query(options)
var ds_res = ds.query(options);
if(ds_res.then){
return ds_res;
}
else{
return ds_res.toPromise();
}
}
});
promise = metaTargetPromise.then(function (result) {
Expand Down Expand Up @@ -298,7 +303,13 @@ function (angular, _, dateMath, moment) {
}

else{
return ds.query(options)
var ds_res = ds.query(options);
if(ds_res.then){
return ds_res;
}
else{
return ds_res.toPromise();
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion dist/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},

"info": {
"version": "0.0.8",
"version": "0.0.9",
"author": {
"name": "Gaurav Shah",
"url": "https://github.com/GoshPosh/grafana-meta-queries"
Expand Down
19 changes: 15 additions & 4 deletions src/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ function (angular, _, dateMath, moment) {
var targetsByRefId = {};
var sets;

if (typeof (options.targets[0].datasource) === 'object') {
if (typeof (options.targets[0].datasource) === 'object') {
sets = _.groupBy(options.targets, target => target.datasource.uid);
} else {
sets = _.groupBy(options.targets, 'datasource');
}

_.forEach(sets, function (targets, dsName) {
// Grafana (8.x.x) sends datasource name as undefined with mixed plugin made as default datasource
// https://github.com/grafana/grafana/issues/36508
Expand Down Expand Up @@ -229,7 +228,13 @@ function (angular, _, dateMath, moment) {
return timeshift(options.targets[0], options, targetsByRefId, datasourceSrv, metaTarget.outputMetricName)
}
else{
return ds.query(options)
var ds_res = ds.query(options);
if(ds_res.then){
return ds_res;
}
else{
return ds_res.toPromise();
}
}
});
promise = metaTargetPromise.then(function (result) {
Expand Down Expand Up @@ -298,7 +303,13 @@ function (angular, _, dateMath, moment) {
}

else{
return ds.query(options)
var ds_res = ds.query(options);
if(ds_res.then){
return ds_res;
}
else{
return ds_res.toPromise();
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},

"info": {
"version": "0.0.8",
"version": "0.0.9",
"author": {
"name": "Gaurav Shah",
"url": "https://github.com/GoshPosh/grafana-meta-queries"
Expand Down

0 comments on commit fecbe8a

Please sign in to comment.