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
6cc7f012
Commit
6cc7f012
authored
May 22, 2014
by
Clicky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup the influx query parsing
parent
3b82ac00
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
15 deletions
+12
-15
src/app/services/influxdb/influxdbDatasource.js
+12
-15
No files found.
src/app/services/influxdb/influxdbDatasource.js
View file @
6cc7f012
...
...
@@ -43,16 +43,13 @@ function (angular, _, kbn) {
var
groupByIndex
=
lowerCaseQueryElements
.
indexOf
(
"group"
);
var
orderIndex
=
lowerCaseQueryElements
.
indexOf
(
"order"
);
var
afterGroup
=
_
.
rest
(
lowerCaseQueryElements
,
groupByIndex
);
for
(
var
i
=
0
;
i
<
afterGroup
.
length
;
i
++
)
{
var
el
=
afterGroup
[
i
];
if
(
el
===
"order"
)
break
;
if
(
/,$/
.
test
(
el
)
&&
_
.
size
(
afterGroup
)
>
i
&&
!
/^time
\(
/
.
test
(
afterGroup
[
i
+
1
]))
{
additionalGroups
.
push
(
queryElements
[
groupByIndex
+
i
+
1
]);
}
}
additionalGroups
=
lowerCaseQueryElements
.
slice
(
groupByIndex
+
1
,
orderIndex
?
orderIndex
:
lowerCaseQueryElements
.
length
).
filter
(
function
(
w
)
{
return
!
/time
\(
/
.
test
(
w
);
});
additionalGroups
=
_
.
map
(
additionalGroups
,
function
(
w
)
{
return
w
.
replace
(
","
,
""
);
});
if
(
whereIndex
!==
-
1
)
{
queryElements
.
splice
(
whereIndex
+
1
,
0
,
timeFilter
,
"and"
);
...
...
@@ -73,14 +70,14 @@ function (angular, _, kbn) {
query
=
queryElements
.
join
(
" "
);
}
else
{
var
template
=
"select [[group]][[group_
add
]] [[func]]([[column]]) as [[column]]_[[func]] from [[series]] "
+
var
template
=
"select [[group]][[group_
comma
]] [[func]]([[column]]) as [[column]]_[[func]] from [[series]] "
+
"where [[timeFilter]] [[condition_add]] [[condition_key]] [[condition_op]] [[condition_value]] "
+
"group by time([[interval]])[[group_
add
]] [[group]] order asc"
;
"group by time([[interval]])[[group_
comma
]] [[group]] order asc"
;
if
(
target
.
column
.
indexOf
(
'-'
)
!==
-
1
||
target
.
column
.
indexOf
(
'.'
)
!==
-
1
)
{
template
=
"select [[group]][[group_
add
]] [[func]](
\"
[[column]]
\"
) as
\"
[[column]]_[[func]]
\"
from [[series]] "
+
template
=
"select [[group]][[group_
comma
]] [[func]](
\"
[[column]]
\"
) as
\"
[[column]]_[[func]]
\"
from [[series]] "
+
"where [[timeFilter]] [[condition_add]] [[condition_key]] [[condition_op]] [[condition_value]] "
+
"group by time([[interval]])[[group_
add
]] [[group]] order asc"
;
"group by time([[interval]])[[group_
comma
]] [[group]] order asc"
;
}
var
templateData
=
{
...
...
@@ -93,7 +90,7 @@ function (angular, _, kbn) {
condition_key
:
target
.
condition_filter
?
target
.
condition_key
:
''
,
condition_op
:
target
.
condition_filter
?
target
.
condition_op
:
''
,
condition_value
:
target
.
condition_filter
?
target
.
condition_value
:
''
,
group_
add
:
target
.
groupby_field_add
&&
target
.
groupby_field
?
','
:
''
,
group_
comma
:
target
.
groupby_field_add
&&
target
.
groupby_field
?
','
:
''
,
group
:
target
.
groupby_field_add
?
target
.
groupby_field
:
''
,
};
...
...
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