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
ae4c6e46
Commit
ae4c6e46
authored
Mar 20, 2018
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mssql: fix precision for time column in table mode
ref #11306
parent
f64c6e49
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
71 deletions
+68
-71
pkg/tsdb/mssql/mssql.go
+1
-1
public/app/plugins/datasource/mssql/response_parser.ts
+1
-1
public/app/plugins/datasource/mssql/specs/datasource_specs.ts
+66
-69
No files found.
pkg/tsdb/mssql/mssql.go
View file @
ae4c6e46
...
@@ -124,7 +124,7 @@ func (e MssqlQueryEndpoint) transformToTable(query *tsdb.Query, rows *core.Rows,
...
@@ -124,7 +124,7 @@ func (e MssqlQueryEndpoint) transformToTable(query *tsdb.Query, rows *core.Rows,
if
timeIndex
!=
-
1
{
if
timeIndex
!=
-
1
{
switch
value
:=
values
[
timeIndex
]
.
(
type
)
{
switch
value
:=
values
[
timeIndex
]
.
(
type
)
{
case
time
.
Time
:
case
time
.
Time
:
values
[
timeIndex
]
=
float64
(
value
.
Unix
())
values
[
timeIndex
]
=
(
float64
(
value
.
Unix
())
*
1000
)
+
float64
(
value
.
Nanosecond
()
/
1e6
)
// in case someone is trying to map times beyond 2262 :D
}
}
}
}
...
...
public/app/plugins/datasource/mssql/response_parser.ts
View file @
ae4c6e46
...
@@ -128,7 +128,7 @@ export default class ResponseParser {
...
@@ -128,7 +128,7 @@ export default class ResponseParser {
const
row
=
table
.
rows
[
i
];
const
row
=
table
.
rows
[
i
];
list
.
push
({
list
.
push
({
annotation
:
options
.
annotation
,
annotation
:
options
.
annotation
,
time
:
Math
.
floor
(
row
[
timeColumnIndex
])
*
1000
,
time
:
row
[
timeColumnIndex
]
,
text
:
row
[
textColumnIndex
],
text
:
row
[
textColumnIndex
],
tags
:
row
[
tagsColumnIndex
]
?
row
[
tagsColumnIndex
].
trim
().
split
(
/
\s
*,
\s
*/
)
:
[],
tags
:
row
[
tagsColumnIndex
]
?
row
[
tagsColumnIndex
].
trim
().
split
(
/
\s
*,
\s
*/
)
:
[],
});
});
...
...
public/app/plugins/datasource/mssql/specs/datasource_specs.ts
View file @
ae4c6e46
import
{
describe
,
beforeEach
,
it
,
expect
,
angularMocks
}
from
'test/lib/common'
;
import
{
describe
,
beforeEach
,
it
,
expect
,
angularMocks
}
from
'test/lib/common'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
helpers
from
'test/specs/helpers'
;
import
helpers
from
'test/specs/helpers'
;
import
{
MssqlDatasource
}
from
'../datasource'
;
import
{
MssqlDatasource
}
from
'../datasource'
;
import
{
CustomVariable
}
from
'app/features/templating/custom_variable'
;
import
{
CustomVariable
}
from
'app/features/templating/custom_variable'
;
describe
(
'MSSQLDatasource'
,
function
()
{
describe
(
'MSSQLDatasource'
,
function
()
{
var
ctx
=
new
helpers
.
ServiceTestContext
();
var
ctx
=
new
helpers
.
ServiceTestContext
();
var
instanceSettings
=
{
name
:
'mssql'
};
var
instanceSettings
=
{
name
:
'mssql'
};
beforeEach
(
angularMocks
.
module
(
'grafana.core'
));
beforeEach
(
angularMocks
.
module
(
'grafana.core'
));
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
ctx
.
providePhase
([
'backendSrv'
]));
beforeEach
(
ctx
.
providePhase
([
'backendSrv'
]));
beforeEach
(
angularMocks
.
inject
(
function
(
$q
,
$rootScope
,
$httpBackend
,
$injector
)
{
beforeEach
(
ctx
.
$q
=
$q
;
angularMocks
.
inject
(
function
(
$q
,
$rootScope
,
$httpBackend
,
$injector
)
{
ctx
.
$httpBackend
=
$httpBackend
;
ctx
.
$q
=
$q
;
ctx
.
$rootScope
=
$rootScope
;
ctx
.
$httpBackend
=
$httpBackend
;
ctx
.
ds
=
$injector
.
instantiate
(
MssqlDatasource
,
{
instanceSettings
:
instanceSettings
});
ctx
.
$rootScope
=
$rootScope
;
$httpBackend
.
when
(
'GET'
,
/
\.
html$/
).
respond
(
''
);
ctx
.
ds
=
$injector
.
instantiate
(
MssqlDatasource
,
{
instanceSettings
:
instanceSettings
});
}));
$httpBackend
.
when
(
'GET'
,
/
\.
html$/
).
respond
(
''
);
})
);
describe
(
'When performing annotationQuery'
,
function
()
{
describe
(
'When performing annotationQuery'
,
function
()
{
let
results
;
let
results
;
...
@@ -28,12 +30,12 @@ describe('MSSQLDatasource', function() {
...
@@ -28,12 +30,12 @@ describe('MSSQLDatasource', function() {
const
options
=
{
const
options
=
{
annotation
:
{
annotation
:
{
name
:
annotationName
,
name
:
annotationName
,
rawQuery
:
'select time, text, tags from table;'
rawQuery
:
'select time, text, tags from table;'
,
},
},
range
:
{
range
:
{
from
:
moment
(
1432288354
),
from
:
moment
(
1432288354
),
to
:
moment
(
1432288401
)
to
:
moment
(
1432288401
)
,
}
}
,
};
};
const
response
=
{
const
response
=
{
...
@@ -42,23 +44,25 @@ describe('MSSQLDatasource', function() {
...
@@ -42,23 +44,25 @@ describe('MSSQLDatasource', function() {
refId
:
annotationName
,
refId
:
annotationName
,
tables
:
[
tables
:
[
{
{
columns
:
[{
text
:
'time'
},
{
text
:
'text'
},
{
text
:
'tags'
}],
columns
:
[{
text
:
'time'
},
{
text
:
'text'
},
{
text
:
'tags'
}],
rows
:
[
rows
:
[
[
1
432288355
,
'some text'
,
'TagA,TagB'
],
[
1
521546171129
,
'some text'
,
'TagA,TagB'
],
[
1
432288390
,
'some text2'
,
' TagB , TagC'
],
[
1
521546531404
,
'some text2'
,
' TagB , TagC'
],
[
1
432288400
,
'some text3'
]
[
1
521546901702
,
'some text3'
],
]
]
,
}
}
,
]
]
,
}
}
,
}
}
,
};
};
beforeEach
(
function
()
{
beforeEach
(
function
()
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
};
};
ctx
.
ds
.
annotationQuery
(
options
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
ds
.
annotationQuery
(
options
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
ctx
.
$rootScope
.
$apply
();
});
});
...
@@ -83,28 +87,26 @@ describe('MSSQLDatasource', function() {
...
@@ -83,28 +87,26 @@ describe('MSSQLDatasource', function() {
results
:
{
results
:
{
tempvar
:
{
tempvar
:
{
meta
:
{
meta
:
{
rowCount
:
3
rowCount
:
3
,
},
},
refId
:
'tempvar'
,
refId
:
'tempvar'
,
tables
:
[
tables
:
[
{
{
columns
:
[{
text
:
'title'
},
{
text
:
'text'
}],
columns
:
[{
text
:
'title'
},
{
text
:
'text'
}],
rows
:
[
rows
:
[[
'aTitle'
,
'some text'
],
[
'aTitle2'
,
'some text2'
],
[
'aTitle3'
,
'some text3'
]],
[
'aTitle'
,
'some text'
],
},
[
'aTitle2'
,
'some text2'
],
],
[
'aTitle3'
,
'some text3'
]
},
]
},
}
]
}
}
};
};
beforeEach
(
function
()
{
beforeEach
(
function
()
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
};
};
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
ctx
.
$rootScope
.
$apply
();
});
});
...
@@ -122,28 +124,26 @@ describe('MSSQLDatasource', function() {
...
@@ -122,28 +124,26 @@ describe('MSSQLDatasource', function() {
results
:
{
results
:
{
tempvar
:
{
tempvar
:
{
meta
:
{
meta
:
{
rowCount
:
3
rowCount
:
3
,
},
},
refId
:
'tempvar'
,
refId
:
'tempvar'
,
tables
:
[
tables
:
[
{
{
columns
:
[{
text
:
'__value'
},
{
text
:
'__text'
}],
columns
:
[{
text
:
'__value'
},
{
text
:
'__text'
}],
rows
:
[
rows
:
[[
'value1'
,
'aTitle'
],
[
'value2'
,
'aTitle2'
],
[
'value3'
,
'aTitle3'
]],
[
'value1'
,
'aTitle'
],
},
[
'value2'
,
'aTitle2'
],
],
[
'value3'
,
'aTitle3'
]
},
]
},
}
]
}
}
};
};
beforeEach
(
function
()
{
beforeEach
(
function
()
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
};
};
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
ctx
.
$rootScope
.
$apply
();
});
});
...
@@ -163,28 +163,26 @@ describe('MSSQLDatasource', function() {
...
@@ -163,28 +163,26 @@ describe('MSSQLDatasource', function() {
results
:
{
results
:
{
tempvar
:
{
tempvar
:
{
meta
:
{
meta
:
{
rowCount
:
3
rowCount
:
3
,
},
},
refId
:
'tempvar'
,
refId
:
'tempvar'
,
tables
:
[
tables
:
[
{
{
columns
:
[{
text
:
'__text'
},
{
text
:
'__value'
}],
columns
:
[{
text
:
'__text'
},
{
text
:
'__value'
}],
rows
:
[
rows
:
[[
'aTitle'
,
'same'
],
[
'aTitle'
,
'same'
],
[
'aTitle'
,
'diff'
]],
[
'aTitle'
,
'same'
],
},
[
'aTitle'
,
'same'
],
],
[
'aTitle'
,
'diff'
]
},
]
},
}
]
}
}
};
};
beforeEach
(
function
()
{
beforeEach
(
function
()
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
};
};
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
ctx
.
$rootScope
.
$apply
();
});
});
...
@@ -197,7 +195,7 @@ describe('MSSQLDatasource', function() {
...
@@ -197,7 +195,7 @@ describe('MSSQLDatasource', function() {
describe
(
'When interpolating variables'
,
()
=>
{
describe
(
'When interpolating variables'
,
()
=>
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
ctx
.
variable
=
new
CustomVariable
({},{});
ctx
.
variable
=
new
CustomVariable
({},
{});
});
});
describe
(
'and value is a string'
,
()
=>
{
describe
(
'and value is a string'
,
()
=>
{
...
@@ -214,23 +212,22 @@ describe('MSSQLDatasource', function() {
...
@@ -214,23 +212,22 @@ describe('MSSQLDatasource', function() {
describe
(
'and value is an array of strings'
,
()
=>
{
describe
(
'and value is an array of strings'
,
()
=>
{
it
(
'should return comma separated quoted values'
,
()
=>
{
it
(
'should return comma separated quoted values'
,
()
=>
{
expect
(
ctx
.
ds
.
interpolateVariable
([
'a'
,
'b'
,
'c'
],
ctx
.
variable
)).
to
.
eql
(
'
\'
a
\'
,
\'
b
\'
,
\'
c
\'
'
);
expect
(
ctx
.
ds
.
interpolateVariable
([
'a'
,
'b'
,
'c'
],
ctx
.
variable
)).
to
.
eql
(
"'a','b','c'"
);
});
});
});
});
describe
(
'and variable allows multi-value and value is a string'
,
()
=>
{
describe
(
'and variable allows multi-value and value is a string'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
ctx
.
variable
.
multi
=
true
;
ctx
.
variable
.
multi
=
true
;
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
,
ctx
.
variable
)).
to
.
eql
(
'
\'
abc
\'
'
);
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
,
ctx
.
variable
)).
to
.
eql
(
"'abc'"
);
});
});
});
});
describe
(
'and variable allows all and value is a string'
,
()
=>
{
describe
(
'and variable allows all and value is a string'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
ctx
.
variable
.
includeAll
=
true
;
ctx
.
variable
.
includeAll
=
true
;
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
,
ctx
.
variable
)).
to
.
eql
(
'
\'
abc
\'
'
);
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
,
ctx
.
variable
)).
to
.
eql
(
"'abc'"
);
});
});
});
});
});
});
});
});
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