diff --git a/src/datasource-zabbix/datasource.js b/src/datasource-zabbix/datasource.js index cd46410..d2bf766 100644 --- a/src/datasource-zabbix/datasource.js +++ b/src/datasource-zabbix/datasource.js @@ -618,8 +618,8 @@ export class ZabbixDatasource { let useTrendsFrom = Math.ceil(dateMath.parse('now-' + this.trendsFrom) / 1000); let useTrendsRange = Math.ceil(utils.parseInterval(this.trendsRange) / 1000); let useTrends = this.trends && ( - (timeFrom <= useTrendsFrom) || - (timeTo - timeFrom >= useTrendsRange) + (timeFrom < useTrendsFrom) || + (timeTo - timeFrom > useTrendsRange) ); return useTrends; } diff --git a/src/datasource-zabbix/specs/datasource.spec.js b/src/datasource-zabbix/specs/datasource.spec.js index f03da65..7c95335 100644 --- a/src/datasource-zabbix/specs/datasource.spec.js +++ b/src/datasource-zabbix/specs/datasource.spec.js @@ -56,7 +56,7 @@ describe('ZabbixDatasource', () => { }); 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 => { ctx.options.range.from = range; @@ -73,7 +73,7 @@ describe('ZabbixDatasource', () => { }); 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 => { ctx.options.range.from = range;