Skip to content

Commit

Permalink
Add maintenance_status to the data
Browse files Browse the repository at this point in the history
  • Loading branch information
nbowes24 committed Feb 14, 2020
1 parent 852f3d9 commit 307c1de
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions exporter/collectors/test_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
logger = logging.getLogger("test_collector")


def parse_test_response(r):
def parse_test_response(r, m):
t = []
for i in r:
for i in r.json():
t.append(
{
"test_id": str(i['TestID']),
"test_type": i['TestType'],
"test_name": i['WebsiteName'],
"test_url": i['WebsiteURL'],
"test_status_int": str(1 if (i["Status"] == "Up") else 0)
"test_status_int": str(1 if (i["Status"] == "Up") else 0),
"maintenance_status_int": str(1 if (str(i["TestID"])) in m else 0)
}
)

Expand Down Expand Up @@ -56,13 +57,14 @@ def collect(self):
try:

maintenance = m.get_maintenance(self.api_key, self.username)
#Grab the test_ids from the response
m_test_id_list = [i['all_tests'] for i in maintenance.json()['data']]
#Flatten the test_ids into a list
m_test_id_flat_list = [item for sublist in m_test_id_list for item in sublist]
tests = t.get_tests(self.api_key, self.username, self.tags)
tests = [y for y in tests.json() if str(y['TestID']) not in m_test_id_flat_list]
parsed_tests = parse_test_response(tests)
parsed_tests = parse_test_response(tests, m_test_id_flat_list)

test_id_list = [i['TestID'] for i in tests]
test_id_list = [i['TestID'] for i in tests.json()]
test_details = []
for i in test_id_list:
test_details.append(
Expand Down

0 comments on commit 307c1de

Please sign in to comment.