Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
d2984f3b
Commit
d2984f3b
authored
Aug 09, 2018
by
Sven Klemm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix rebase error
parent
acd1acba
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
4 deletions
+5
-4
pkg/tsdb/postgres/macros.go
+2
-2
pkg/tsdb/postgres/macros_test.go
+2
-2
pkg/tsdb/postgres/postgres_test.go
+1
-0
No files found.
pkg/tsdb/postgres/macros.go
View file @
d2984f3b
...
...
@@ -132,9 +132,9 @@ func (m *postgresMacroEngine) evaluateMacro(name string, args []string) (string,
}
if
m
.
query
.
DataSource
.
JsonData
.
Get
(
"timescaledb"
)
.
MustBool
()
{
return
fmt
.
Sprintf
(
"time_bucket('%vs',%s)
AS time
"
,
interval
.
Seconds
(),
args
[
0
]),
nil
return
fmt
.
Sprintf
(
"time_bucket('%vs',%s)"
,
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
return
fmt
.
Sprintf
(
"floor(extract(epoch from %s)/%v)*%v"
,
args
[
0
],
interval
.
Seconds
(),
interval
.
Seconds
()),
nil
}
case
"__timeGroupAlias"
:
tg
,
err
:=
m
.
evaluateMacro
(
"__timeGroup"
,
args
)
...
...
pkg/tsdb/postgres/macros_test.go
View file @
d2984f3b
...
...
@@ -92,7 +92,7 @@ func TestMacroEngine(t *testing.T) {
sql
,
err
:=
engine
.
Interpolate
(
queryTS
,
timeRange
,
"GROUP BY $__timeGroup(time_column,'5m')"
)
So
(
err
,
ShouldBeNil
)
So
(
sql
,
ShouldEqual
,
"GROUP BY time_bucket('300s',time_column)
AS time
"
)
So
(
sql
,
ShouldEqual
,
"GROUP BY time_bucket('300s',time_column)"
)
})
Convey
(
"interpolate __timeGroup function with spaces between args and TimescaleDB enabled"
,
func
()
{
...
...
@@ -100,7 +100,7 @@ func TestMacroEngine(t *testing.T) {
sql
,
err
:=
engine
.
Interpolate
(
queryTS
,
timeRange
,
"GROUP BY $__timeGroup(time_column , '5m')"
)
So
(
err
,
ShouldBeNil
)
So
(
sql
,
ShouldEqual
,
"GROUP BY time_bucket('300s',time_column)
AS time
"
)
So
(
sql
,
ShouldEqual
,
"GROUP BY time_bucket('300s',time_column)"
)
})
Convey
(
"interpolate __timeTo function"
,
func
()
{
...
...
pkg/tsdb/postgres/postgres_test.go
View file @
d2984f3b
...
...
@@ -311,6 +311,7 @@ func TestPostgres(t *testing.T) {
query
:=
&
tsdb
.
TsdbQuery
{
Queries
:
[]
*
tsdb
.
Query
{
{
DataSource
:
&
models
.
DataSource
{
JsonData
:
simplejson
.
New
()},
Model
:
simplejson
.
NewFromAny
(
map
[
string
]
interface
{}{
"rawSql"
:
"SELECT $__timeGroup(time, '5m', previous), avg(value) as value FROM metric GROUP BY 1 ORDER BY 1"
,
"format"
:
"time_series"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment