From 62269bb894122200009af5166b58e6660e8c4d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 6 Dec 2016 08:56:01 +0100 Subject: [PATCH] change(influxdb): always specify absolute time range in milliseconds, refactoring #6571 --- .../app/plugins/datasource/influxdb/datasource.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/public/app/plugins/datasource/influxdb/datasource.ts b/public/app/plugins/datasource/influxdb/datasource.ts index 2fc3a945e57..28f13752dbe 100644 --- a/public/app/plugins/datasource/influxdb/datasource.ts +++ b/public/app/plugins/datasource/influxdb/datasource.ts @@ -250,11 +250,9 @@ export default class InfluxDatasource { }; getTimeFilter(options) { - var inMS = elapsed < (5 * 60000); - - var from = this.getInfluxTime(options.rangeRaw.from, false, inMS); - var until = this.getInfluxTime(options.rangeRaw.to, true, inMS); - var fromIsAbsolute = from[from.length-1] === 's'; + var from = this.getInfluxTime(options.rangeRaw.from, false); + var until = this.getInfluxTime(options.rangeRaw.to, true); + var fromIsAbsolute = from[from.length-1] === 'ms'; if (until === 'now()' && !fromIsAbsolute) { return 'time > ' + from; @@ -263,7 +261,7 @@ export default class InfluxDatasource { return 'time > ' + from + ' and time < ' + until; } - getInfluxTime(date, roundUp, inMS) { + getInfluxTime(date, roundUp) { if (_.isString(date)) { if (date === 'now') { return 'now()'; @@ -278,10 +276,7 @@ export default class InfluxDatasource { date = dateMath.parse(date, roundUp); } - if (inMS) { - return date.valueOf() + 'ms'; - } - return (date.valueOf() / 1000).toFixed(0) + 's'; + return date.valueOf() + 'ms'; } }