FIX: InfluxDB query WHERE clause
Change-Id: I0809b60864dd11b58904cd999d940ccf94446451
This commit is contained in:
parent
052ac2fde3
commit
c2a2b82b82
@ -37,6 +37,11 @@ def build_influxdb_query(live_query, measurement, group_by=[], limit=None):
|
||||
|
||||
query = ['SELECT * FROM', measurement]
|
||||
|
||||
if live_query:
|
||||
filters = json.loads(live_query.filters)
|
||||
if filters:
|
||||
query.append(_build_where_clause(filters))
|
||||
|
||||
if group_by:
|
||||
query.append('GROUP BY')
|
||||
query.append(', '.join(group_by))
|
||||
@ -44,11 +49,6 @@ def build_influxdb_query(live_query, measurement, group_by=[], limit=None):
|
||||
if limit is not None:
|
||||
query.append('LIMIT %d' % limit)
|
||||
|
||||
if live_query:
|
||||
filters = json.loads(live_query.filters)
|
||||
if filters:
|
||||
query.append(_build_where_clause(filters))
|
||||
|
||||
return ' '.join(query)
|
||||
|
||||
|
||||
|
@ -196,9 +196,9 @@ class TestStatusHosts(functionalTest.FunctionalTest):
|
||||
|
||||
self.assertEqual(
|
||||
httpretty.last_request().querystring['q'],
|
||||
["SELECT * FROM HOST_STATE GROUP BY host_name, address, childs"
|
||||
" LIMIT 1 WHERE host_name!='localhost' "
|
||||
"AND description!='test_keystone'"]
|
||||
["SELECT * FROM HOST_STATE WHERE host_name!='localhost' "
|
||||
"AND description!='test_keystone' "
|
||||
"GROUP BY host_name, address, childs LIMIT 1"]
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
|
Loading…
x
Reference in New Issue
Block a user