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
3955133f
Commit
3955133f
authored
Aug 14, 2018
by
Sven Klemm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't pass datasource to newPostgresMacroEngine
parent
3552a4cb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
13 deletions
+7
-13
pkg/tsdb/postgres/macros.go
+2
-5
pkg/tsdb/postgres/macros_test.go
+2
-7
pkg/tsdb/postgres/postgres.go
+3
-1
No files found.
pkg/tsdb/postgres/macros.go
View file @
3955133f
...
...
@@ -7,7 +7,6 @@ import (
"strings"
"time"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/tsdb"
)
...
...
@@ -21,10 +20,8 @@ type postgresMacroEngine struct {
timescaledb
bool
}
func
newPostgresMacroEngine
(
datasource
*
models
.
DataSource
)
tsdb
.
SqlMacroEngine
{
engine
:=
&
postgresMacroEngine
{}
engine
.
timescaledb
=
datasource
.
JsonData
.
Get
(
"timescaledb"
)
.
MustBool
(
false
)
return
engine
func
newPostgresMacroEngine
(
timescaledb
bool
)
tsdb
.
SqlMacroEngine
{
return
&
postgresMacroEngine
{
timescaledb
:
timescaledb
}
}
func
(
m
*
postgresMacroEngine
)
Interpolate
(
query
*
tsdb
.
Query
,
timeRange
*
tsdb
.
TimeRange
,
sql
string
)
(
string
,
error
)
{
...
...
pkg/tsdb/postgres/macros_test.go
View file @
3955133f
...
...
@@ -6,19 +6,14 @@ import (
"testing"
"time"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/tsdb"
.
"github.com/smartystreets/goconvey/convey"
)
func
TestMacroEngine
(
t
*
testing
.
T
)
{
Convey
(
"MacroEngine"
,
t
,
func
()
{
datasource
:=
&
models
.
DataSource
{
JsonData
:
simplejson
.
New
()}
engine
:=
newPostgresMacroEngine
(
datasource
)
datasourceTS
:=
&
models
.
DataSource
{
JsonData
:
simplejson
.
New
()}
datasourceTS
.
JsonData
.
Set
(
"timescaledb"
,
true
)
engineTS
:=
newPostgresMacroEngine
(
datasourceTS
)
engine
:=
newPostgresMacroEngine
(
false
)
engineTS
:=
newPostgresMacroEngine
(
true
)
query
:=
&
tsdb
.
Query
{}
Convey
(
"Given a time range between 2018-04-12 00:00 and 2018-04-12 00:05"
,
func
()
{
...
...
pkg/tsdb/postgres/postgres.go
View file @
3955133f
...
...
@@ -32,7 +32,9 @@ func newPostgresQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndp
log
:
logger
,
}
return
tsdb
.
NewSqlQueryEndpoint
(
&
config
,
&
rowTransformer
,
newPostgresMacroEngine
(
datasource
),
logger
)
timescaledb
:=
datasource
.
JsonData
.
Get
(
"timescaledb"
)
.
MustBool
(
false
)
return
tsdb
.
NewSqlQueryEndpoint
(
&
config
,
&
rowTransformer
,
newPostgresMacroEngine
(
timescaledb
),
logger
)
}
func
generateConnectionString
(
datasource
*
models
.
DataSource
)
string
{
...
...
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