Private GIT

Skip to content
Snippets Groups Projects
Commit 04c58956 authored by Josh Smith's avatar Josh Smith
Browse files

admin can select tags for data now

parent 3a392f20
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,9 @@ def pkt_loss(data): ...@@ -42,6 +42,9 @@ def pkt_loss(data):
def tag_selection(data): def tag_selection(data):
tags = DB_TAGS tags = DB_TAGS
if tags is None:
return None
# tag_switch takes in _data and attaches CLIoutput to more readable ids
tag_switch = { tag_switch = {
'isp': data['isp'], 'isp': data['isp'],
'interface': data['interface']['name'], 'interface': data['interface']['name'],
...@@ -59,12 +62,11 @@ def tag_selection(data): ...@@ -59,12 +62,11 @@ def tag_selection(data):
'speedtest_id': data['result']['id'], 'speedtest_id': data['result']['id'],
'speedtest_url': data['result']['url'] 'speedtest_url': data['result']['url']
} }
options = {} options = {}
if tags == '':
return None
else:
tags = tags.split(',') tags = tags.split(',')
for tag in tags: for tag in tags:
# split the tag string, strip and add selected tags to {options} with corresponding tag_switch data
tag = tag.strip() tag = tag.strip()
options[tag] = tag_switch[tag] options[tag] = tag_switch[tag]
return options return options
...@@ -110,7 +112,12 @@ def format_for_influx(cliout): ...@@ -110,7 +112,12 @@ def format_for_influx(cliout):
} }
} }
] ]
tags = tag_selection(data)
if tags is None:
return influx_data
else:
for measurement in influx_data:
measurement['tags'] = tags
return influx_data return influx_data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment