fix(influxdb): fixed handling of relative time ranges like last x years, or last x months, fixes #3067
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
### Bug Fixes
|
||||
* **dashboard**: fix for collapse row by clicking on row title, fixes [#3065](https://github.com/grafana/grafana/issues/3065)
|
||||
* **influxdb**: fix for relative time ranges `last x months` and `last x years`, fixes [#3067](https://github.com/grafana/grafana/issues/3067)
|
||||
|
||||
# 2.5 (2015-10-28)
|
||||
|
||||
|
||||
@@ -192,8 +192,12 @@ function (angular, _, dateMath, InfluxSeries, InfluxQueryBuilder) {
|
||||
if (date === 'now') {
|
||||
return 'now()';
|
||||
}
|
||||
if (date.indexOf('now-') >= 0 && date.indexOf('/') === -1) {
|
||||
return date.replace('now', 'now()').replace('-', ' - ');
|
||||
|
||||
var parts = /^now-(\d+)([d|h|m|s])$/.exec(date);
|
||||
if (parts) {
|
||||
var amount = parseInt(parts[1]);
|
||||
var unit = parts[2];
|
||||
return 'now() - ' + amount + unit;
|
||||
}
|
||||
date = dateMath.parse(date, roundUp);
|
||||
}
|
||||
|
||||
@@ -270,9 +270,14 @@ function (angular, _, dateMath, InfluxSeries, InfluxQueryBuilder) {
|
||||
if (date === 'now') {
|
||||
return 'now()';
|
||||
}
|
||||
if (date.indexOf('now-') >= 0 && date.indexOf('/') === -1) {
|
||||
return date.replace('now', 'now()');
|
||||
|
||||
var parts = /^now-(\d+)([d|h|m|s])$/.exec(date);
|
||||
if (parts) {
|
||||
var amount = parseInt(parts[1]);
|
||||
var unit = parts[2];
|
||||
return 'now()-' + amount + unit;
|
||||
}
|
||||
|
||||
date = dateMath.parse(date, roundUp);
|
||||
}
|
||||
return (date.valueOf() / 1000).toFixed(0) + 's';
|
||||
|
||||
Reference in New Issue
Block a user