Merge pull request #10042 from andrei-kolosok/master

grafana-10039: fix query time range ends in the past
This commit is contained in:
Carl Bergquist 2017-11-30 16:41:43 +01:00 committed by GitHub
commit 142c3a6bc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -17,7 +17,7 @@ import (
"github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tsdb" "github.com/grafana/grafana/pkg/tsdb"
opentracing "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go"
) )
type GraphiteExecutor struct { type GraphiteExecutor struct {
@ -158,7 +158,7 @@ func formatTimeRange(input string) string {
if input == "now" { if input == "now" {
return input return input
} }
return strings.Replace(strings.Replace(input, "m", "min", -1), "M", "mon", -1) return strings.Replace(strings.Replace(strings.Replace(input, "now", "", -1), "m", "min", -1), "M", "mon", -1)
} }
func fixIntervalFormat(target string) string { func fixIntervalFormat(target string) string {

View File

@ -18,14 +18,14 @@ func TestGraphiteFunctions(t *testing.T) {
Convey("formatting time range for now-1m", func() { Convey("formatting time range for now-1m", func() {
timeRange := formatTimeRange("now-1m") timeRange := formatTimeRange("now-1m")
So(timeRange, ShouldEqual, "now-1min") So(timeRange, ShouldEqual, "-1min")
}) })
Convey("formatting time range for now-1M", func() { Convey("formatting time range for now-1M", func() {
timeRange := formatTimeRange("now-1M") timeRange := formatTimeRange("now-1M")
So(timeRange, ShouldEqual, "now-1mon") So(timeRange, ShouldEqual, "-1mon")
}) })