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
ae5e004b
Commit
ae5e004b
authored
Apr 24, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysql: time filter macro updated
parent
c485fed7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
pkg/tsdb/mysql/macros.go
+1
-1
pkg/tsdb/mysql/macros_test.go
+1
-1
No files found.
pkg/tsdb/mysql/macros.go
View file @
ae5e004b
...
@@ -73,7 +73,7 @@ func (m *MySqlMacroEngine) EvaluateMacro(name string, args []string) (string, er
...
@@ -73,7 +73,7 @@ func (m *MySqlMacroEngine) EvaluateMacro(name string, args []string) (string, er
if
len
(
args
)
==
0
{
if
len
(
args
)
==
0
{
return
""
,
fmt
.
Errorf
(
"missing time column argument for macro %v"
,
name
)
return
""
,
fmt
.
Errorf
(
"missing time column argument for macro %v"
,
name
)
}
}
return
fmt
.
Sprintf
(
"
UNIX_TIMESTAMP(%s) > %d AND UNIX_TIMESTAMP(%s) < %d
"
,
args
[
0
],
uint64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
),
args
[
0
],
uint64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
return
fmt
.
Sprintf
(
"
%s > FROM_UNIXTIME(%d) AND %s < FROM_UNIXTIME(%d)
"
,
args
[
0
],
uint64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
),
args
[
0
],
uint64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
default
:
default
:
return
""
,
fmt
.
Errorf
(
"Unknown macro %v"
,
name
)
return
""
,
fmt
.
Errorf
(
"Unknown macro %v"
,
name
)
}
}
...
...
pkg/tsdb/mysql/macros_test.go
View file @
ae5e004b
...
@@ -36,7 +36,7 @@ func TestMacroEngine(t *testing.T) {
...
@@ -36,7 +36,7 @@ func TestMacroEngine(t *testing.T) {
sql
,
err
:=
engine
.
Interpolate
(
"WHERE $__timeFilter(time_column)"
)
sql
,
err
:=
engine
.
Interpolate
(
"WHERE $__timeFilter(time_column)"
)
So
(
err
,
ShouldBeNil
)
So
(
err
,
ShouldBeNil
)
So
(
sql
,
ShouldEqual
,
"WHERE
UNIX_TIMESTAMP(time_column) > 18446744066914186738 AND UNIX_TIMESTAMP(time_column) < 18446744066914187038
"
)
So
(
sql
,
ShouldEqual
,
"WHERE
time_column > FROM_UNIXTIME(18446744066914186738) AND time_column < FROM_UNIXTIME(18446744066914187038)
"
)
})
})
})
})
...
...
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