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
15e6a426
Commit
15e6a426
authored
Jun 29, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed OR statement for influxdb 0.9 editor, #1525
parent
11170dd3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
10 deletions
+29
-10
public/app/plugins/datasource/influxdb/queryBuilder.js
+15
-10
public/test/specs/influx09-querybuilder-specs.js
+14
-0
No files found.
public/app/plugins/datasource/influxdb/queryBuilder.js
View file @
15e6a426
...
...
@@ -8,11 +8,16 @@ function (_) {
this
.
target
=
target
;
}
function
renderTagCondition
(
key
,
value
)
{
if
(
value
&&
value
[
0
]
===
'/'
&&
value
[
value
.
length
-
1
]
===
'/'
)
{
return
key
+
' =~ '
+
value
;
function
renderTagCondition
(
tag
,
index
)
{
var
str
=
""
;
if
(
index
>
0
)
{
str
=
(
tag
.
condition
||
'AND'
)
+
' '
;
}
return
key
+
" = '"
+
value
+
"'"
;
if
(
tag
.
value
&&
tag
.
value
[
0
]
===
'/'
&&
tag
.
value
[
tag
.
value
.
length
-
1
]
===
'/'
)
{
return
str
+
tag
.
key
+
' =~ '
+
tag
.
value
;
}
return
str
+
tag
.
key
+
" = '"
+
tag
.
value
+
"'"
;
}
var
p
=
InfluxQueryBuilder
.
prototype
;
...
...
@@ -49,12 +54,12 @@ function (_) {
if
(
tag
.
key
===
withKey
)
{
return
memo
;
}
memo
.
push
(
renderTagCondition
(
tag
.
key
,
tag
.
value
));
memo
.
push
(
renderTagCondition
(
tag
,
memo
.
length
));
return
memo
;
},
[]);
if
(
whereConditions
.
length
>
0
)
{
query
+=
' WHERE '
+
whereConditions
.
join
(
'
AND
'
);
query
+=
' WHERE '
+
whereConditions
.
join
(
' '
);
}
}
...
...
@@ -78,12 +83,12 @@ function (_) {
query
+=
aggregationFunc
+
'(value)'
;
query
+=
' FROM '
+
measurement
+
' WHERE '
;
var
conditions
=
_
.
map
(
target
.
tags
,
function
(
tag
)
{
return
renderTagCondition
(
tag
.
key
,
tag
.
value
);
var
conditions
=
_
.
map
(
target
.
tags
,
function
(
tag
,
index
)
{
return
renderTagCondition
(
tag
,
index
);
});
conditions
.
push
(
'$timeFilter'
);
query
+=
conditions
.
join
(
' AND '
);
query
+=
conditions
.
join
(
' '
);
query
+=
(
conditions
.
length
>
0
?
' AND '
:
''
)
+
'$timeFilter'
;
query
+=
' GROUP BY time($interval)'
;
if
(
target
.
groupByTags
&&
target
.
groupByTags
.
length
>
0
)
{
...
...
public/test/specs/influx09-querybuilder-specs.js
View file @
15e6a426
...
...
@@ -52,6 +52,20 @@ define([
});
});
describe
(
'series with tags OR condition'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
measurement
:
'cpu'
,
tags
:
[{
key
:
'hostname'
,
value
:
'server1'
},
{
key
:
'hostname'
,
value
:
'server2'
,
condition
:
"OR"
}]
});
var
query
=
builder
.
build
();
it
(
'should generate correct query'
,
function
()
{
expect
(
query
).
to
.
be
(
'SELECT mean(value) FROM "cpu" WHERE hostname =
\'
server1
\'
OR hostname =
\'
server2
\'
AND '
+
'$timeFilter GROUP BY time($interval) ORDER BY asc'
);
});
});
describe
(
'series with groupByTag'
,
function
()
{
it
(
'should generate correct query'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
...
...
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