change timescaledb to checkbox instead of select

This commit is contained in:
Sven Klemm
2018-08-09 10:05:35 +02:00
parent b987aee7cf
commit c3aad10047
4 changed files with 4 additions and 28 deletions
+1 -1
View File
@@ -131,7 +131,7 @@ func (m *postgresMacroEngine) evaluateMacro(name string, args []string) (string,
}
}
if m.query.DataSource.JsonData.Get("timescaledb").MustString("auto") == "enabled" {
if m.query.DataSource.JsonData.Get("timescaledb").MustBool() {
return fmt.Sprintf("time_bucket('%vs',%s) AS time", interval.Seconds(), args[0]), nil
} else {
return fmt.Sprintf("floor(extract(epoch from %s)/%v)*%v AS time", args[0], interval.Seconds(), interval.Seconds()), nil
+1 -1
View File
@@ -17,7 +17,7 @@ func TestMacroEngine(t *testing.T) {
engine := newPostgresMacroEngine()
query := &tsdb.Query{DataSource: &models.DataSource{JsonData: simplejson.New()}}
queryTS := &tsdb.Query{DataSource: &models.DataSource{JsonData: simplejson.New()}}
queryTS.DataSource.JsonData.Set("timescaledb", "enabled")
queryTS.DataSource.JsonData.Set("timescaledb", true)
Convey("Given a time range between 2018-04-12 00:00 and 2018-04-12 00:05", func() {
from := time.Date(2018, 4, 12, 18, 0, 0, 0, time.UTC)