From 0534d43a6eeaf94c359200ba8e3a0a18f8411e02 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Mon, 28 Nov 2016 14:57:36 -0800 Subject: [PATCH] use ms when query less then 5 mins --- .../app/plugins/datasource/influxdb/datasource.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/public/app/plugins/datasource/influxdb/datasource.ts b/public/app/plugins/datasource/influxdb/datasource.ts index a6d4459c7ff..2fc3a945e57 100644 --- a/public/app/plugins/datasource/influxdb/datasource.ts +++ b/public/app/plugins/datasource/influxdb/datasource.ts @@ -250,8 +250,10 @@ export default class InfluxDatasource { }; getTimeFilter(options) { - var from = this.getInfluxTime(options.rangeRaw.from, false); - var until = this.getInfluxTime(options.rangeRaw.to, true); + 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'; if (until === 'now()' && !fromIsAbsolute) { @@ -261,7 +263,7 @@ export default class InfluxDatasource { return 'time > ' + from + ' and time < ' + until; } - getInfluxTime(date, roundUp) { + getInfluxTime(date, roundUp, inMS) { if (_.isString(date)) { if (date === 'now') { return 'now()'; @@ -275,7 +277,11 @@ export default class InfluxDatasource { } date = dateMath.parse(date, roundUp); } - return date.valueOf() + 'ms'; + + if (inMS) { + return date.valueOf() + 'ms'; + } + return (date.valueOf() / 1000).toFixed(0) + 's'; } }