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
de0d409a
Unverified
Commit
de0d409a
authored
May 02, 2018
by
Marcus Efraimsson
Committed by
GitHub
May 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Opportunities to unindent code (unindent)"
parent
6dcb9e69
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
26 deletions
+33
-26
pkg/api/common.go
+3
-1
pkg/components/dynmap/dynmap.go
+12
-6
pkg/components/simplejson/simplejson.go
+3
-1
pkg/middleware/dashboard_redirect.go
+7
-6
pkg/tsdb/mssql/mssql.go
+2
-3
pkg/tsdb/mysql/mysql.go
+2
-3
pkg/tsdb/postgres/postgres.go
+2
-3
pkg/tsdb/sql_engine.go
+2
-3
No files found.
pkg/api/common.go
View file @
de0d409a
...
@@ -99,9 +99,11 @@ func Error(status int, message string, err error) *NormalResponse {
...
@@ -99,9 +99,11 @@ func Error(status int, message string, err error) *NormalResponse {
data
[
"message"
]
=
message
data
[
"message"
]
=
message
}
}
if
err
!=
nil
&&
setting
.
Env
!=
setting
.
PROD
{
if
err
!=
nil
{
if
setting
.
Env
!=
setting
.
PROD
{
data
[
"error"
]
=
err
.
Error
()
data
[
"error"
]
=
err
.
Error
()
}
}
}
resp
:=
JSON
(
status
,
data
)
resp
:=
JSON
(
status
,
data
)
...
...
pkg/components/dynmap/dynmap.go
View file @
de0d409a
...
@@ -639,9 +639,7 @@ func (v *Value) Object() (*Object, error) {
...
@@ -639,9 +639,7 @@ func (v *Value) Object() (*Object, error) {
valid
=
true
valid
=
true
}
}
if
!
valid
{
if
valid
{
return
nil
,
ErrNotObject
}
obj
:=
new
(
Object
)
obj
:=
new
(
Object
)
obj
.
valid
=
valid
obj
.
valid
=
valid
...
@@ -650,6 +648,7 @@ func (v *Value) Object() (*Object, error) {
...
@@ -650,6 +648,7 @@ func (v *Value) Object() (*Object, error) {
if
valid
{
if
valid
{
for
key
,
element
:=
range
v
.
data
.
(
map
[
string
]
interface
{})
{
for
key
,
element
:=
range
v
.
data
.
(
map
[
string
]
interface
{})
{
m
[
key
]
=
&
Value
{
element
,
true
}
m
[
key
]
=
&
Value
{
element
,
true
}
}
}
}
}
...
@@ -657,6 +656,9 @@ func (v *Value) Object() (*Object, error) {
...
@@ -657,6 +656,9 @@ func (v *Value) Object() (*Object, error) {
obj
.
m
=
m
obj
.
m
=
m
return
obj
,
nil
return
obj
,
nil
}
return
nil
,
ErrNotObject
}
}
// Attempts to typecast the current value into an object arrau.
// Attempts to typecast the current value into an object arrau.
...
@@ -676,9 +678,8 @@ func (v *Value) ObjectArray() ([]*Object, error) {
...
@@ -676,9 +678,8 @@ func (v *Value) ObjectArray() ([]*Object, error) {
// Unsure if this is a good way to use slices, it's probably not
// Unsure if this is a good way to use slices, it's probably not
var
slice
[]
*
Object
var
slice
[]
*
Object
if
!
valid
{
if
valid
{
return
nil
,
ErrNotObjectArray
}
for
_
,
element
:=
range
v
.
data
.
([]
interface
{})
{
for
_
,
element
:=
range
v
.
data
.
([]
interface
{})
{
childValue
:=
Value
{
element
,
true
}
childValue
:=
Value
{
element
,
true
}
childObject
,
err
:=
childValue
.
Object
()
childObject
,
err
:=
childValue
.
Object
()
...
@@ -688,7 +689,12 @@ func (v *Value) ObjectArray() ([]*Object, error) {
...
@@ -688,7 +689,12 @@ func (v *Value) ObjectArray() ([]*Object, error) {
}
}
slice
=
append
(
slice
,
childObject
)
slice
=
append
(
slice
,
childObject
)
}
}
return
slice
,
nil
return
slice
,
nil
}
return
nil
,
ErrNotObjectArray
}
}
// Attempts to typecast the current value into a string.
// Attempts to typecast the current value into a string.
...
...
pkg/components/simplejson/simplejson.go
View file @
de0d409a
...
@@ -168,9 +168,11 @@ func (j *Json) GetPath(branch ...string) *Json {
...
@@ -168,9 +168,11 @@ func (j *Json) GetPath(branch ...string) *Json {
// js.Get("top_level").Get("array").GetIndex(1).Get("key").Int()
// js.Get("top_level").Get("array").GetIndex(1).Get("key").Int()
func
(
j
*
Json
)
GetIndex
(
index
int
)
*
Json
{
func
(
j
*
Json
)
GetIndex
(
index
int
)
*
Json
{
a
,
err
:=
j
.
Array
()
a
,
err
:=
j
.
Array
()
if
err
==
nil
&&
len
(
a
)
>
index
{
if
err
==
nil
{
if
len
(
a
)
>
index
{
return
&
Json
{
a
[
index
]}
return
&
Json
{
a
[
index
]}
}
}
}
return
&
Json
{
nil
}
return
&
Json
{
nil
}
}
}
...
...
pkg/middleware/dashboard_redirect.go
View file @
de0d409a
...
@@ -24,12 +24,12 @@ func RedirectFromLegacyDashboardURL() macaron.Handler {
...
@@ -24,12 +24,12 @@ func RedirectFromLegacyDashboardURL() macaron.Handler {
return
func
(
c
*
m
.
ReqContext
)
{
return
func
(
c
*
m
.
ReqContext
)
{
slug
:=
c
.
Params
(
"slug"
)
slug
:=
c
.
Params
(
"slug"
)
if
slug
==
""
{
if
slug
!=
""
{
return
}
if
url
,
err
:=
getDashboardURLBySlug
(
c
.
OrgId
,
slug
);
err
==
nil
{
if
url
,
err
:=
getDashboardURLBySlug
(
c
.
OrgId
,
slug
);
err
==
nil
{
url
=
fmt
.
Sprintf
(
"%s?%s"
,
url
,
c
.
Req
.
URL
.
RawQuery
)
url
=
fmt
.
Sprintf
(
"%s?%s"
,
url
,
c
.
Req
.
URL
.
RawQuery
)
c
.
Redirect
(
url
,
301
)
c
.
Redirect
(
url
,
301
)
return
}
}
}
}
}
}
}
...
@@ -39,16 +39,17 @@ func RedirectFromLegacyDashboardSoloURL() macaron.Handler {
...
@@ -39,16 +39,17 @@ func RedirectFromLegacyDashboardSoloURL() macaron.Handler {
slug
:=
c
.
Params
(
"slug"
)
slug
:=
c
.
Params
(
"slug"
)
renderRequest
:=
c
.
QueryBool
(
"render"
)
renderRequest
:=
c
.
QueryBool
(
"render"
)
if
slug
==
""
{
if
slug
!=
""
{
return
}
if
url
,
err
:=
getDashboardURLBySlug
(
c
.
OrgId
,
slug
);
err
==
nil
{
if
url
,
err
:=
getDashboardURLBySlug
(
c
.
OrgId
,
slug
);
err
==
nil
{
if
renderRequest
&&
strings
.
Contains
(
url
,
setting
.
AppSubUrl
)
{
if
renderRequest
&&
strings
.
Contains
(
url
,
setting
.
AppSubUrl
)
{
url
=
strings
.
Replace
(
url
,
setting
.
AppSubUrl
,
""
,
1
)
url
=
strings
.
Replace
(
url
,
setting
.
AppSubUrl
,
""
,
1
)
}
}
url
=
strings
.
Replace
(
url
,
"/d/"
,
"/d-solo/"
,
1
)
url
=
strings
.
Replace
(
url
,
"/d/"
,
"/d-solo/"
,
1
)
url
=
fmt
.
Sprintf
(
"%s?%s"
,
url
,
c
.
Req
.
URL
.
RawQuery
)
url
=
fmt
.
Sprintf
(
"%s?%s"
,
url
,
c
.
Req
.
URL
.
RawQuery
)
c
.
Redirect
(
url
,
301
)
c
.
Redirect
(
url
,
301
)
return
}
}
}
}
}
}
}
pkg/tsdb/mssql/mssql.go
View file @
de0d409a
...
@@ -298,9 +298,7 @@ func (e MssqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
...
@@ -298,9 +298,7 @@ func (e MssqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
key
:=
elem
.
Value
.
(
string
)
key
:=
elem
.
Value
.
(
string
)
result
.
Series
=
append
(
result
.
Series
,
pointsBySeries
[
key
])
result
.
Series
=
append
(
result
.
Series
,
pointsBySeries
[
key
])
if
!
fillMissing
{
if
fillMissing
{
break
}
series
:=
pointsBySeries
[
key
]
series
:=
pointsBySeries
[
key
]
// fill in values from last fetched value till interval end
// fill in values from last fetched value till interval end
intervalStart
:=
series
.
Points
[
len
(
series
.
Points
)
-
1
][
1
]
.
Float64
intervalStart
:=
series
.
Points
[
len
(
series
.
Points
)
-
1
][
1
]
.
Float64
...
@@ -313,6 +311,7 @@ func (e MssqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
...
@@ -313,6 +311,7 @@ func (e MssqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
rowCount
++
rowCount
++
}
}
}
}
}
result
.
Meta
.
Set
(
"rowCount"
,
rowCount
)
result
.
Meta
.
Set
(
"rowCount"
,
rowCount
)
return
nil
return
nil
...
...
pkg/tsdb/mysql/mysql.go
View file @
de0d409a
...
@@ -309,9 +309,7 @@ func (e MysqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
...
@@ -309,9 +309,7 @@ func (e MysqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
key
:=
elem
.
Value
.
(
string
)
key
:=
elem
.
Value
.
(
string
)
result
.
Series
=
append
(
result
.
Series
,
pointsBySeries
[
key
])
result
.
Series
=
append
(
result
.
Series
,
pointsBySeries
[
key
])
if
!
fillMissing
{
if
fillMissing
{
break
}
series
:=
pointsBySeries
[
key
]
series
:=
pointsBySeries
[
key
]
// fill in values from last fetched value till interval end
// fill in values from last fetched value till interval end
intervalStart
:=
series
.
Points
[
len
(
series
.
Points
)
-
1
][
1
]
.
Float64
intervalStart
:=
series
.
Points
[
len
(
series
.
Points
)
-
1
][
1
]
.
Float64
...
@@ -324,6 +322,7 @@ func (e MysqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
...
@@ -324,6 +322,7 @@ func (e MysqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
rowCount
++
rowCount
++
}
}
}
}
}
result
.
Meta
.
Set
(
"rowCount"
,
rowCount
)
result
.
Meta
.
Set
(
"rowCount"
,
rowCount
)
return
nil
return
nil
...
...
pkg/tsdb/postgres/postgres.go
View file @
de0d409a
...
@@ -289,9 +289,7 @@ func (e PostgresQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *co
...
@@ -289,9 +289,7 @@ func (e PostgresQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *co
key
:=
elem
.
Value
.
(
string
)
key
:=
elem
.
Value
.
(
string
)
result
.
Series
=
append
(
result
.
Series
,
pointsBySeries
[
key
])
result
.
Series
=
append
(
result
.
Series
,
pointsBySeries
[
key
])
if
!
fillMissing
{
if
fillMissing
{
break
}
series
:=
pointsBySeries
[
key
]
series
:=
pointsBySeries
[
key
]
// fill in values from last fetched value till interval end
// fill in values from last fetched value till interval end
intervalStart
:=
series
.
Points
[
len
(
series
.
Points
)
-
1
][
1
]
.
Float64
intervalStart
:=
series
.
Points
[
len
(
series
.
Points
)
-
1
][
1
]
.
Float64
...
@@ -304,6 +302,7 @@ func (e PostgresQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *co
...
@@ -304,6 +302,7 @@ func (e PostgresQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *co
rowCount
++
rowCount
++
}
}
}
}
}
result
.
Meta
.
Set
(
"rowCount"
,
rowCount
)
result
.
Meta
.
Set
(
"rowCount"
,
rowCount
)
return
nil
return
nil
...
...
pkg/tsdb/sql_engine.go
View file @
de0d409a
...
@@ -141,9 +141,7 @@ func (e *DefaultSqlEngine) Query(
...
@@ -141,9 +141,7 @@ func (e *DefaultSqlEngine) Query(
// ConvertSqlTimeColumnToEpochMs converts column named time to unix timestamp in milliseconds
// ConvertSqlTimeColumnToEpochMs converts column named time to unix timestamp in milliseconds
// to make native datetime types and epoch dates work in annotation and table queries.
// to make native datetime types and epoch dates work in annotation and table queries.
func
ConvertSqlTimeColumnToEpochMs
(
values
RowValues
,
timeIndex
int
)
{
func
ConvertSqlTimeColumnToEpochMs
(
values
RowValues
,
timeIndex
int
)
{
if
timeIndex
<
0
{
if
timeIndex
>=
0
{
return
}
switch
value
:=
values
[
timeIndex
]
.
(
type
)
{
switch
value
:=
values
[
timeIndex
]
.
(
type
)
{
case
time
.
Time
:
case
time
.
Time
:
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
(
value
.
UnixNano
()))
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
(
value
.
UnixNano
()))
...
@@ -188,6 +186,7 @@ func ConvertSqlTimeColumnToEpochMs(values RowValues, timeIndex int) {
...
@@ -188,6 +186,7 @@ func ConvertSqlTimeColumnToEpochMs(values RowValues, timeIndex int) {
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
(
*
value
))
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
(
*
value
))
}
}
}
}
}
}
}
// ConvertSqlValueColumnToFloat converts timeseries value column to float.
// ConvertSqlValueColumnToFloat converts timeseries value column to float.
...
...
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