mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
use ms when query less then 5 mins
This commit is contained in:
parent
1ce0d81736
commit
0534d43a6e
@ -250,8 +250,10 @@ export default class InfluxDatasource {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getTimeFilter(options) {
|
getTimeFilter(options) {
|
||||||
var from = this.getInfluxTime(options.rangeRaw.from, false);
|
var inMS = elapsed < (5 * 60000);
|
||||||
var until = this.getInfluxTime(options.rangeRaw.to, true);
|
|
||||||
|
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 fromIsAbsolute = from[from.length-1] === 's';
|
||||||
|
|
||||||
if (until === 'now()' && !fromIsAbsolute) {
|
if (until === 'now()' && !fromIsAbsolute) {
|
||||||
@ -261,7 +263,7 @@ export default class InfluxDatasource {
|
|||||||
return 'time > ' + from + ' and time < ' + until;
|
return 'time > ' + from + ' and time < ' + until;
|
||||||
}
|
}
|
||||||
|
|
||||||
getInfluxTime(date, roundUp) {
|
getInfluxTime(date, roundUp, inMS) {
|
||||||
if (_.isString(date)) {
|
if (_.isString(date)) {
|
||||||
if (date === 'now') {
|
if (date === 'now') {
|
||||||
return 'now()';
|
return 'now()';
|
||||||
@ -275,7 +277,11 @@ export default class InfluxDatasource {
|
|||||||
}
|
}
|
||||||
date = dateMath.parse(date, roundUp);
|
date = dateMath.parse(date, roundUp);
|
||||||
}
|
}
|
||||||
return date.valueOf() + 'ms';
|
|
||||||
|
if (inMS) {
|
||||||
|
return date.valueOf() + 'ms';
|
||||||
|
}
|
||||||
|
return (date.valueOf() / 1000).toFixed(0) + 's';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user