-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_issue_data.py
57 lines (52 loc) · 1.91 KB
/
fetch_issue_data.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
56
57
import os
import aiohttp
from gidgethub.aiohttp import GitHubAPI
import asyncio
import gspread
import re
from oauth2client.service_account import ServiceAccountCredentials
scope = [
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.file'
]
defined_labels = ['enhancement', 'bug', 'help wanted', 'question', 'wontfix', 'feature', 'good first issue']
file_name = 'client_key.json'
creds = ServiceAccountCredentials.from_json_keyfile_name(file_name, scope)
client = gspread.authorize(creds)
sheet = client.open('Dataset Github').sheet1
async def main():
async with aiohttp.ClientSession() as session:
gh = GitHubAPI(session, "mhk19", oauth_token=os.getenv("GH_AUTH"))
count = 1
i = 0
while(True):
array = (await gh.getitem('/repos/mozilla/fxa/issues?page='+str(i)+'&per_page=100'))
print(i)
if len(array)==0:
break
start = count+1
rows = []
for issue in array:
x = {
"enhancement": 0,
"bug": 0,
"help wanted": 0,
"question": 0,
"wontfix": 0,
"feature": 0,
"good first issue": 0
}
for label in issue['labels']:
k = label['name']
print(k)
m = (re.sub(r"[^a-zA-Z0-9]+", '', k))
if m in defined_labels:
x[m] = 1
title = issue['title']+' '+issue['body']
count = count + 1
rows.append([count, title, x["enhancement"], x["bug"], x["help wanted"], x["question"], x["wontfix"], x["feature"], x["good first issue"]])
sheet.insert_rows(rows, start)
i = i+1
print(count)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())