-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
55 lines (47 loc) · 1.73 KB
/
main.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
50
51
52
53
54
55
import requests
from datetime import datetime
from datetime import timedelta
import json
tries = 3
for retrytimes in range(tries):
try:
headers = {
"Accept": "application/vnd.github+json",
}
baseurl = "https://api.github.com/repos/MicrosoftEdge/WebView2Feedback/issues"
utcdate = (datetime.utcnow() - timedelta(days = 1)).date()
issueList = []
scanover = False
page = 1
while(not scanover):
url = baseurl + '?page=' + str(page)
response = requests.get(url, headers=headers)
issues = response.json()
for item in issues:
date_object = datetime.strptime(item['created_at'], '%Y-%m-%dT%H:%M:%SZ').date()
if(date_object < utcdate):
scanover = True
break
newissue = {}
#newissue['issueName'] = item['title']
newissue['issueName'] = """asdf"t"""
newissue['issueLink'] = item['html_url']
tags = []
for label in item['labels']:
tags.append(label['name'])
newissue['issueTags'] = tags
if(item['assignee'] is not None):
newissue['issueAssignee'] = item['assignee']['login']
else:newissue['issueAssignee'] = None
if(date_object == utcdate):
issueList.append(newissue)
page = page + 1
result = {'total': len(issueList), 'issueList': issueList}
resultjson = json.dumps(result)
print(resultjson)
except KeyError as e:
if retrytimes < tries - 1:
continue
else:
raise
break