-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_mismatched_parents.py
49 lines (36 loc) · 1.07 KB
/
find_mismatched_parents.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
import requests
def main():
projects = ['ANSTRAT', 'AAP-RFE', 'AAP', 'AAH', 'AA']
all_rows = []
for project in projects:
url = f'http://localhost:5000/api/tickets_parents?project={project}'
rr = requests.get(url)
rows = rr.json()
all_rows.extend(rows)
bad_rows = []
for row in all_rows:
links = set()
for k,v in row.items():
if k == 'key' or k == 'type':
continue
if not v:
continue
links.add(v)
if not links:
continue
if len(list(links)) == 1:
continue
bad_rows.append(row)
cols = ['key', 'type', 'parent_link', 'epic_link', 'feature_link']
sheet = ','.join(cols) + '\n'
for row in bad_rows:
vals = [row.get(x) or '' for x in cols]
try:
sheet += ','.join(vals) + '\n'
except TypeError:
import epdb; epdb.st()
with open('/tmp/test.csv', 'w') as f:
f.write(sheet)
if __name__ == "__main__":
main()