fix(influxdb): handles time(auto) like time($interval)

closes #6997
This commit is contained in:
bergquist
2016-12-21 10:01:20 +01:00
parent 497a1fcefc
commit 8cef4cc74e
2 changed files with 10 additions and 2 deletions

View File

@@ -111,7 +111,7 @@ func getDefinedInterval(query *Query, queryContext *tsdb.QueryContext) string {
func functionRenderer(query *Query, queryContext *tsdb.QueryContext, part *QueryPart, innerExpr string) string {
for i, param := range part.Params {
if param == "$interval" {
if param == "$interval" || param == "auto" {
if query.Interval != "" {
part.Params[i] = getDefinedInterval(query, queryContext)
} else {

View File

@@ -37,7 +37,7 @@ func TestInfluxdbQueryPart(t *testing.T) {
So(res, ShouldEqual, "bottom(value, 3)")
})
Convey("render time", func() {
Convey("render time with $interval", func() {
part, err := NewQueryPart("time", []string{"$interval"})
So(err, ShouldBeNil)
@@ -45,6 +45,14 @@ func TestInfluxdbQueryPart(t *testing.T) {
So(res, ShouldEqual, "time(200ms)")
})
Convey("render time with auto", func() {
part, err := NewQueryPart("time", []string{"auto"})
So(err, ShouldBeNil)
res := part.Render(query, queryContext, "")
So(res, ShouldEqual, "time(200ms)")
})
Convey("render time interval >10s", func() {
part, err := NewQueryPart("time", []string{"$interval"})
So(err, ShouldBeNil)