use trends only if interval strictly greater than specified

This commit is contained in:
Alexander Zobnin
2018-10-31 21:19:42 +03:00
parent a41df652b2
commit ae32dfb9a7
2 changed files with 4 additions and 4 deletions

View File

@@ -618,8 +618,8 @@ export class ZabbixDatasource {
let useTrendsFrom = Math.ceil(dateMath.parse('now-' + this.trendsFrom) / 1000); let useTrendsFrom = Math.ceil(dateMath.parse('now-' + this.trendsFrom) / 1000);
let useTrendsRange = Math.ceil(utils.parseInterval(this.trendsRange) / 1000); let useTrendsRange = Math.ceil(utils.parseInterval(this.trendsRange) / 1000);
let useTrends = this.trends && ( let useTrends = this.trends && (
(timeFrom <= useTrendsFrom) || (timeFrom < useTrendsFrom) ||
(timeTo - timeFrom >= useTrendsRange) (timeTo - timeFrom > useTrendsRange)
); );
return useTrends; return useTrends;
} }

View File

@@ -56,7 +56,7 @@ describe('ZabbixDatasource', () => {
}); });
it('should use trends if it enabled and time more than trendsFrom', (done) => { it('should use trends if it enabled and time more than trendsFrom', (done) => {
let ranges = ['now-7d', 'now-168h', 'now-1M', 'now-1y']; let ranges = ['now-8d', 'now-169h', 'now-1M', 'now-1y'];
_.forEach(ranges, range => { _.forEach(ranges, range => {
ctx.options.range.from = range; ctx.options.range.from = range;
@@ -73,7 +73,7 @@ describe('ZabbixDatasource', () => {
}); });
it('shouldnt use trends if it enabled and time less than trendsFrom', (done) => { it('shouldnt use trends if it enabled and time less than trendsFrom', (done) => {
let ranges = ['now-6d', 'now-167h', 'now-1h', 'now-30m', 'now-30s']; let ranges = ['now-7d', 'now-168h', 'now-1h', 'now-30m', 'now-30s'];
_.forEach(ranges, range => { _.forEach(ranges, range => {
ctx.options.range.from = range; ctx.options.range.from = range;