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
e6f2811b
Commit
e6f2811b
authored
May 28, 2018
by
Leonard Gram
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sql: seconds epochs are now correctly converted to ms.
Closes #12061
parent
83b7bbd6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
pkg/tsdb/sql_engine.go
+2
-2
pkg/tsdb/sql_engine_test.go
+10
-3
No files found.
pkg/tsdb/sql_engine.go
View file @
e6f2811b
...
...
@@ -144,10 +144,10 @@ func ConvertSqlTimeColumnToEpochMs(values RowValues, timeIndex int) {
if
timeIndex
>=
0
{
switch
value
:=
values
[
timeIndex
]
.
(
type
)
{
case
time
.
Time
:
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
(
value
.
UnixNano
())
)
values
[
timeIndex
]
=
float64
(
value
.
UnixNano
())
/
float64
(
time
.
Millisecond
)
case
*
time
.
Time
:
if
value
!=
nil
{
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
((
*
value
)
.
UnixNano
())
)
values
[
timeIndex
]
=
float64
((
*
value
)
.
UnixNano
())
/
float64
(
time
.
Millisecond
)
}
case
int64
:
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
value
)))
...
...
pkg/tsdb/sql_engine_test.go
View file @
e6f2811b
...
...
@@ -12,14 +12,17 @@ import (
func
TestSqlEngine
(
t
*
testing
.
T
)
{
Convey
(
"SqlEngine"
,
t
,
func
()
{
dt
:=
time
.
Date
(
2018
,
3
,
14
,
21
,
20
,
6
,
int
(
527345
*
time
.
Microsecond
),
time
.
UTC
)
earlyDt
:=
time
.
Date
(
1970
,
3
,
14
,
21
,
20
,
6
,
int
(
527345
*
time
.
Microsecond
),
time
.
UTC
)
Convey
(
"Given row values with time.Time as time columns"
,
func
()
{
var
nilPointer
*
time
.
Time
fixtures
:=
make
([]
interface
{},
3
)
fixtures
:=
make
([]
interface
{},
5
)
fixtures
[
0
]
=
dt
fixtures
[
1
]
=
&
dt
fixtures
[
2
]
=
nilPointer
fixtures
[
2
]
=
earlyDt
fixtures
[
3
]
=
&
earlyDt
fixtures
[
4
]
=
nilPointer
for
i
:=
range
fixtures
{
ConvertSqlTimeColumnToEpochMs
(
fixtures
,
i
)
...
...
@@ -27,9 +30,13 @@ func TestSqlEngine(t *testing.T) {
Convey
(
"When converting them should return epoch time with millisecond precision "
,
func
()
{
expected
:=
float64
(
dt
.
UnixNano
())
/
float64
(
time
.
Millisecond
)
expectedEarly
:=
float64
(
earlyDt
.
UnixNano
())
/
float64
(
time
.
Millisecond
)
So
(
fixtures
[
0
]
.
(
float64
),
ShouldEqual
,
expected
)
So
(
fixtures
[
1
]
.
(
float64
),
ShouldEqual
,
expected
)
So
(
fixtures
[
2
],
ShouldBeNil
)
So
(
fixtures
[
2
]
.
(
float64
),
ShouldEqual
,
expectedEarly
)
So
(
fixtures
[
3
]
.
(
float64
),
ShouldEqual
,
expectedEarly
)
So
(
fixtures
[
4
],
ShouldBeNil
)
})
})
...
...
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