Commit 13760b1b by Torkel Ödegaard

fix(influxdb): fixed handling of relative time ranges like last x years, or last…

fix(influxdb): fixed handling of relative time ranges like last x years, or last x months, fixes #3067
parent 299a2457
......@@ -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';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment