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
04d071aa
Unverified
Commit
04d071aa
authored
May 02, 2018
by
Marcus Efraimsson
Committed by
GitHub
May 02, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11797 from grafana/revert-11775-unindent
Revert "Opportunities to unindent code (unindent)"
parents
6dcb9e69
de0d409a
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
133 additions
and
126 deletions
+133
-126
pkg/api/common.go
+4
-2
pkg/components/dynmap/dynmap.go
+29
-23
pkg/components/simplejson/simplejson.go
+4
-2
pkg/middleware/dashboard_redirect.go
+16
-15
pkg/tsdb/mssql/mssql.go
+12
-13
pkg/tsdb/mysql/mysql.go
+12
-13
pkg/tsdb/postgres/postgres.go
+12
-13
pkg/tsdb/sql_engine.go
+44
-45
No files found.
pkg/api/common.go
View file @
04d071aa
...
...
@@ -99,8 +99,10 @@ func Error(status int, message string, err error) *NormalResponse {
data
[
"message"
]
=
message
}
if
err
!=
nil
&&
setting
.
Env
!=
setting
.
PROD
{
data
[
"error"
]
=
err
.
Error
()
if
err
!=
nil
{
if
setting
.
Env
!=
setting
.
PROD
{
data
[
"error"
]
=
err
.
Error
()
}
}
resp
:=
JSON
(
status
,
data
)
...
...
pkg/components/dynmap/dynmap.go
View file @
04d071aa
...
...
@@ -639,24 +639,26 @@ func (v *Value) Object() (*Object, error) {
valid
=
true
}
if
!
valid
{
return
nil
,
ErrNotObject
}
obj
:=
new
(
Object
)
obj
.
valid
=
valid
if
valid
{
obj
:=
new
(
Object
)
obj
.
valid
=
valid
m
:=
make
(
map
[
string
]
*
Value
)
m
:=
make
(
map
[
string
]
*
Value
)
if
valid
{
for
key
,
element
:=
range
v
.
data
.
(
map
[
string
]
interface
{})
{
m
[
key
]
=
&
Value
{
element
,
true
}
if
valid
{
for
key
,
element
:=
range
v
.
data
.
(
map
[
string
]
interface
{})
{
m
[
key
]
=
&
Value
{
element
,
true
}
}
}
}
obj
.
data
=
v
.
data
obj
.
m
=
m
obj
.
data
=
v
.
data
obj
.
m
=
m
return
obj
,
nil
return
obj
,
nil
}
return
nil
,
ErrNotObject
}
// Attempts to typecast the current value into an object arrau.
...
...
@@ -676,19 +678,23 @@ func (v *Value) ObjectArray() ([]*Object, error) {
// Unsure if this is a good way to use slices, it's probably not
var
slice
[]
*
Object
if
!
valid
{
return
nil
,
ErrNotObjectArray
}
for
_
,
element
:=
range
v
.
data
.
([]
interface
{})
{
childValue
:=
Value
{
element
,
true
}
childObject
,
err
:=
childValue
.
Object
()
if
valid
{
if
err
!=
nil
{
return
nil
,
ErrNotObjectArray
for
_
,
element
:=
range
v
.
data
.
([]
interface
{})
{
childValue
:=
Value
{
element
,
true
}
childObject
,
err
:=
childValue
.
Object
()
if
err
!=
nil
{
return
nil
,
ErrNotObjectArray
}
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.
...
...
pkg/components/simplejson/simplejson.go
View file @
04d071aa
...
...
@@ -168,8 +168,10 @@ func (j *Json) GetPath(branch ...string) *Json {
// js.Get("top_level").Get("array").GetIndex(1).Get("key").Int()
func
(
j
*
Json
)
GetIndex
(
index
int
)
*
Json
{
a
,
err
:=
j
.
Array
()
if
err
==
nil
&&
len
(
a
)
>
index
{
return
&
Json
{
a
[
index
]}
if
err
==
nil
{
if
len
(
a
)
>
index
{
return
&
Json
{
a
[
index
]}
}
}
return
&
Json
{
nil
}
}
...
...
pkg/middleware/dashboard_redirect.go
View file @
04d071aa
...
...
@@ -24,12 +24,12 @@ func RedirectFromLegacyDashboardURL() macaron.Handler {
return
func
(
c
*
m
.
ReqContext
)
{
slug
:=
c
.
Params
(
"slug"
)
if
slug
=
=
""
{
return
}
if
url
,
err
:=
getDashboardURLBySlug
(
c
.
OrgId
,
slug
);
err
==
nil
{
url
=
fmt
.
Sprintf
(
"%s?%s"
,
url
,
c
.
Req
.
URL
.
RawQuery
)
c
.
Redirect
(
url
,
301
)
if
slug
!
=
""
{
if
url
,
err
:=
getDashboardURLBySlug
(
c
.
OrgId
,
slug
);
err
==
nil
{
url
=
fmt
.
Sprintf
(
"%s?%s"
,
url
,
c
.
Req
.
URL
.
RawQuery
)
c
.
Redirect
(
url
,
301
)
return
}
}
}
}
...
...
@@ -39,16 +39,17 @@ func RedirectFromLegacyDashboardSoloURL() macaron.Handler {
slug
:=
c
.
Params
(
"slug"
)
renderRequest
:=
c
.
QueryBool
(
"render"
)
if
slug
==
""
{
return
}
if
url
,
err
:=
getDashboardURLBySlug
(
c
.
OrgId
,
slug
);
err
==
nil
{
if
renderRequest
&&
strings
.
Contains
(
url
,
setting
.
AppSubUrl
)
{
url
=
strings
.
Replace
(
url
,
setting
.
AppSubUrl
,
""
,
1
)
if
slug
!=
""
{
if
url
,
err
:=
getDashboardURLBySlug
(
c
.
OrgId
,
slug
);
err
==
nil
{
if
renderRequest
&&
strings
.
Contains
(
url
,
setting
.
AppSubUrl
)
{
url
=
strings
.
Replace
(
url
,
setting
.
AppSubUrl
,
""
,
1
)
}
url
=
strings
.
Replace
(
url
,
"/d/"
,
"/d-solo/"
,
1
)
url
=
fmt
.
Sprintf
(
"%s?%s"
,
url
,
c
.
Req
.
URL
.
RawQuery
)
c
.
Redirect
(
url
,
301
)
return
}
url
=
strings
.
Replace
(
url
,
"/d/"
,
"/d-solo/"
,
1
)
url
=
fmt
.
Sprintf
(
"%s?%s"
,
url
,
c
.
Req
.
URL
.
RawQuery
)
c
.
Redirect
(
url
,
301
)
}
}
}
pkg/tsdb/mssql/mssql.go
View file @
04d071aa
...
...
@@ -298,19 +298,18 @@ func (e MssqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
key
:=
elem
.
Value
.
(
string
)
result
.
Series
=
append
(
result
.
Series
,
pointsBySeries
[
key
])
if
!
fillMissing
{
break
}
series
:=
pointsBySeries
[
key
]
// fill in values from last fetched value till interval end
intervalStart
:=
series
.
Points
[
len
(
series
.
Points
)
-
1
][
1
]
.
Float64
intervalEnd
:=
float64
(
tsdbQuery
.
TimeRange
.
MustGetTo
()
.
UnixNano
()
/
1e6
)
// align interval start
intervalStart
=
math
.
Floor
(
intervalStart
/
fillInterval
)
*
fillInterval
for
i
:=
intervalStart
+
fillInterval
;
i
<
intervalEnd
;
i
+=
fillInterval
{
series
.
Points
=
append
(
series
.
Points
,
tsdb
.
TimePoint
{
fillValue
,
null
.
FloatFrom
(
i
)})
rowCount
++
if
fillMissing
{
series
:=
pointsBySeries
[
key
]
// fill in values from last fetched value till interval end
intervalStart
:=
series
.
Points
[
len
(
series
.
Points
)
-
1
][
1
]
.
Float64
intervalEnd
:=
float64
(
tsdbQuery
.
TimeRange
.
MustGetTo
()
.
UnixNano
()
/
1e6
)
// align interval start
intervalStart
=
math
.
Floor
(
intervalStart
/
fillInterval
)
*
fillInterval
for
i
:=
intervalStart
+
fillInterval
;
i
<
intervalEnd
;
i
+=
fillInterval
{
series
.
Points
=
append
(
series
.
Points
,
tsdb
.
TimePoint
{
fillValue
,
null
.
FloatFrom
(
i
)})
rowCount
++
}
}
}
...
...
pkg/tsdb/mysql/mysql.go
View file @
04d071aa
...
...
@@ -309,19 +309,18 @@ func (e MysqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
key
:=
elem
.
Value
.
(
string
)
result
.
Series
=
append
(
result
.
Series
,
pointsBySeries
[
key
])
if
!
fillMissing
{
break
}
series
:=
pointsBySeries
[
key
]
// fill in values from last fetched value till interval end
intervalStart
:=
series
.
Points
[
len
(
series
.
Points
)
-
1
][
1
]
.
Float64
intervalEnd
:=
float64
(
tsdbQuery
.
TimeRange
.
MustGetTo
()
.
UnixNano
()
/
1e6
)
// align interval start
intervalStart
=
math
.
Floor
(
intervalStart
/
fillInterval
)
*
fillInterval
for
i
:=
intervalStart
+
fillInterval
;
i
<
intervalEnd
;
i
+=
fillInterval
{
series
.
Points
=
append
(
series
.
Points
,
tsdb
.
TimePoint
{
fillValue
,
null
.
FloatFrom
(
i
)})
rowCount
++
if
fillMissing
{
series
:=
pointsBySeries
[
key
]
// fill in values from last fetched value till interval end
intervalStart
:=
series
.
Points
[
len
(
series
.
Points
)
-
1
][
1
]
.
Float64
intervalEnd
:=
float64
(
tsdbQuery
.
TimeRange
.
MustGetTo
()
.
UnixNano
()
/
1e6
)
// align interval start
intervalStart
=
math
.
Floor
(
intervalStart
/
fillInterval
)
*
fillInterval
for
i
:=
intervalStart
+
fillInterval
;
i
<
intervalEnd
;
i
+=
fillInterval
{
series
.
Points
=
append
(
series
.
Points
,
tsdb
.
TimePoint
{
fillValue
,
null
.
FloatFrom
(
i
)})
rowCount
++
}
}
}
...
...
pkg/tsdb/postgres/postgres.go
View file @
04d071aa
...
...
@@ -289,19 +289,18 @@ func (e PostgresQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *co
key
:=
elem
.
Value
.
(
string
)
result
.
Series
=
append
(
result
.
Series
,
pointsBySeries
[
key
])
if
!
fillMissing
{
break
}
series
:=
pointsBySeries
[
key
]
// fill in values from last fetched value till interval end
intervalStart
:=
series
.
Points
[
len
(
series
.
Points
)
-
1
][
1
]
.
Float64
intervalEnd
:=
float64
(
tsdbQuery
.
TimeRange
.
MustGetTo
()
.
UnixNano
()
/
1e6
)
// align interval start
intervalStart
=
math
.
Floor
(
intervalStart
/
fillInterval
)
*
fillInterval
for
i
:=
intervalStart
+
fillInterval
;
i
<
intervalEnd
;
i
+=
fillInterval
{
series
.
Points
=
append
(
series
.
Points
,
tsdb
.
TimePoint
{
fillValue
,
null
.
FloatFrom
(
i
)})
rowCount
++
if
fillMissing
{
series
:=
pointsBySeries
[
key
]
// fill in values from last fetched value till interval end
intervalStart
:=
series
.
Points
[
len
(
series
.
Points
)
-
1
][
1
]
.
Float64
intervalEnd
:=
float64
(
tsdbQuery
.
TimeRange
.
MustGetTo
()
.
UnixNano
()
/
1e6
)
// align interval start
intervalStart
=
math
.
Floor
(
intervalStart
/
fillInterval
)
*
fillInterval
for
i
:=
intervalStart
+
fillInterval
;
i
<
intervalEnd
;
i
+=
fillInterval
{
series
.
Points
=
append
(
series
.
Points
,
tsdb
.
TimePoint
{
fillValue
,
null
.
FloatFrom
(
i
)})
rowCount
++
}
}
}
...
...
pkg/tsdb/sql_engine.go
View file @
04d071aa
...
...
@@ -141,51 +141,50 @@ func (e *DefaultSqlEngine) Query(
// ConvertSqlTimeColumnToEpochMs converts column named time to unix timestamp in milliseconds
// to make native datetime types and epoch dates work in annotation and table queries.
func
ConvertSqlTimeColumnToEpochMs
(
values
RowValues
,
timeIndex
int
)
{
if
timeIndex
<
0
{
return
}
switch
value
:=
values
[
timeIndex
]
.
(
type
)
{
case
time
.
Time
:
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
(
value
.
UnixNano
()))
case
*
time
.
Time
:
if
value
!=
nil
{
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
((
*
value
)
.
UnixNano
()))
}
case
int64
:
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
value
)))
case
*
int64
:
if
value
!=
nil
{
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
*
value
)))
}
case
uint64
:
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
value
)))
case
*
uint64
:
if
value
!=
nil
{
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
*
value
)))
}
case
int32
:
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
value
)))
case
*
int32
:
if
value
!=
nil
{
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
*
value
)))
}
case
uint32
:
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
value
)))
case
*
uint32
:
if
value
!=
nil
{
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
*
value
)))
}
case
float64
:
values
[
timeIndex
]
=
EpochPrecisionToMs
(
value
)
case
*
float64
:
if
value
!=
nil
{
values
[
timeIndex
]
=
EpochPrecisionToMs
(
*
value
)
}
case
float32
:
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
(
value
))
case
*
float32
:
if
value
!=
nil
{
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
(
*
value
))
if
timeIndex
>=
0
{
switch
value
:=
values
[
timeIndex
]
.
(
type
)
{
case
time
.
Time
:
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
(
value
.
UnixNano
()))
case
*
time
.
Time
:
if
value
!=
nil
{
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
((
*
value
)
.
UnixNano
()))
}
case
int64
:
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
value
)))
case
*
int64
:
if
value
!=
nil
{
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
*
value
)))
}
case
uint64
:
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
value
)))
case
*
uint64
:
if
value
!=
nil
{
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
*
value
)))
}
case
int32
:
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
value
)))
case
*
int32
:
if
value
!=
nil
{
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
*
value
)))
}
case
uint32
:
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
value
)))
case
*
uint32
:
if
value
!=
nil
{
values
[
timeIndex
]
=
int64
(
EpochPrecisionToMs
(
float64
(
*
value
)))
}
case
float64
:
values
[
timeIndex
]
=
EpochPrecisionToMs
(
value
)
case
*
float64
:
if
value
!=
nil
{
values
[
timeIndex
]
=
EpochPrecisionToMs
(
*
value
)
}
case
float32
:
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
(
value
))
case
*
float32
:
if
value
!=
nil
{
values
[
timeIndex
]
=
EpochPrecisionToMs
(
float64
(
*
value
))
}
}
}
}
...
...
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