Fix timeshift() function with multiple targets, closes #338

This commit is contained in:
Alexander Zobnin
2017-05-16 12:02:49 +03:00
parent ea59983721
commit 48d21837b4
4 changed files with 25 additions and 25 deletions

View File

@@ -235,13 +235,6 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
value: function query(options) {
var _this = this;
var timeFrom = Math.ceil(dateMath.parse(options.range.from) / 1000);
var timeTo = Math.ceil(dateMath.parse(options.range.to) / 1000);
var useTrendsFrom = Math.ceil(dateMath.parse('now-' + this.trendsFrom) / 1000);
var useTrendsRange = Math.ceil(utils.parseInterval(this.trendsRange) / 1000);
var useTrends = this.trends && (timeFrom <= useTrendsFrom || timeTo - timeFrom >= useTrendsRange);
// Get alerts for current panel
if (this.alertingEnabled) {
this.alertQuery(options).then(function (alert) {
@@ -258,6 +251,9 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
// Create request for each target
var promises = _.map(options.targets, function (target) {
var timeFrom = Math.ceil(dateMath.parse(options.range.from) / 1000);
var timeTo = Math.ceil(dateMath.parse(options.range.to) / 1000);
// Prevent changes of original object
target = _.cloneDeep(target);
_this.replaceTargetVariables(target, options);
@@ -274,6 +270,10 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
timeTo = time_to;
}
var useTrendsFrom = Math.ceil(dateMath.parse('now-' + _this.trendsFrom) / 1000);
var useTrendsRange = Math.ceil(utils.parseInterval(_this.trendsRange) / 1000);
var useTrends = _this.trends && (timeFrom <= useTrendsFrom || timeTo - timeFrom >= useTrendsRange);
// Metrics or Text query mode
if (target.mode !== 1) {
// Migrate old targets

File diff suppressed because one or more lines are too long