Add Horrible Hacks for Group By Queries endpoint
This perpetuates the hacks that we added for :dashboardTime: so that they will also work for :interval:. We should really find a better way to do this.pull/1609/head
parent
95862a9bbc
commit
4e7ec0b2a8
|
@ -11,6 +11,12 @@ import (
|
|||
// Convert changes an InfluxQL query to a QueryConfig
|
||||
func Convert(influxQL string) (chronograf.QueryConfig, error) {
|
||||
itsDashboardTime := false
|
||||
intervalTime := false
|
||||
if strings.Contains(influxQL, ":interval:") {
|
||||
influxQL = strings.Replace(influxQL, ":interval:", "time(1234s)", 1)
|
||||
intervalTime = true
|
||||
}
|
||||
|
||||
if strings.Contains(influxQL, ":dashboardTime:") {
|
||||
influxQL = strings.Replace(influxQL, ":dashboardTime:", "now() - 15m", 1)
|
||||
itsDashboardTime = true
|
||||
|
@ -25,6 +31,10 @@ func Convert(influxQL string) (chronograf.QueryConfig, error) {
|
|||
influxQL = strings.Replace(influxQL, "now() - 15m", ":dashboardTime:", 1)
|
||||
}
|
||||
|
||||
if intervalTime {
|
||||
influxQL = strings.Replace(influxQL, "time(1234s)", ":interval:", 1)
|
||||
}
|
||||
|
||||
raw := chronograf.QueryConfig{
|
||||
RawText: &influxQL,
|
||||
Fields: []chronograf.Field{},
|
||||
|
@ -104,7 +114,11 @@ func Convert(influxQL string) (chronograf.QueryConfig, error) {
|
|||
if !ok {
|
||||
return raw, nil
|
||||
}
|
||||
if intervalTime {
|
||||
qc.GroupBy.Time = "auto"
|
||||
} else {
|
||||
qc.GroupBy.Time = lit.String()
|
||||
}
|
||||
case *influxql.VarRef:
|
||||
qc.GroupBy.Tags = append(qc.GroupBy.Tags, v.Val)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue