From 751b322c1a248362fe7dba586858e278d165d83f Mon Sep 17 00:00:00 2001 From: Kw Huang Date: Thu, 29 Nov 2018 00:18:02 -0500 Subject: [PATCH 1/4] Q1 done, Q2 done but def wrong.. --- task-10/task10.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 task-10/task10.py diff --git a/task-10/task10.py b/task-10/task10.py new file mode 100644 index 0000000..c1fd345 --- /dev/null +++ b/task-10/task10.py @@ -0,0 +1,20 @@ +import json +import requests +import numpy as np + + +# Q1: Find out which user has submitted the most PRs in astropgh/learning-by-doing +# repos = json.loads(requests.get('https://api.github.com/repos/astropgh/learning-by-doing/pulls').text) +# prs_users = [repo['user']['login'] for repo in repos] +# print(prs_users[np.argmax([prs_users.count(user) for user in prs_users])]) + +# Q2: Find out how many commits have been made to the master branch of numpy/numpy in 2018 October +repos = json.loads(requests.get('https://api.github.com/repos/numpy/numpy/commits').text) +commit_dates = [repo['commit']['author']['date'] for repo in repos] +print(len([commit_date for commit_date in commit_dates if '2018-10' in commit_date])) + + + + +# print(type(requests.get('https://api.github.com/orgs/astropgh/repos').text)) +# print(len(type(repos))) From 1c3e7dd8f141f32be4a33e3dd4d410ac1e7212be Mon Sep 17 00:00:00 2001 From: Kw Huang Date: Sun, 2 Dec 2018 22:55:46 -0500 Subject: [PATCH 2/4] done q2 but note the best way --- task-10/task10.py | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/task-10/task10.py b/task-10/task10.py index c1fd345..0f80312 100644 --- a/task-10/task10.py +++ b/task-10/task10.py @@ -2,19 +2,29 @@ import requests import numpy as np +""" +Q1: Find out which user has submitted the most PRs in astropgh/learning-by-doing +""" +repos = json.loads(requests.get('https://api.github.com/repos/astropgh/learning-by-doing/pulls').text) +prs_users = [repo['user']['login'] for repo in repos] +print(prs_users[np.argmax([prs_users.count(user) for user in prs_users])]) -# Q1: Find out which user has submitted the most PRs in astropgh/learning-by-doing -# repos = json.loads(requests.get('https://api.github.com/repos/astropgh/learning-by-doing/pulls').text) -# prs_users = [repo['user']['login'] for repo in repos] -# print(prs_users[np.argmax([prs_users.count(user) for user in prs_users])]) +""" +Q2: Find out how many commits have been made to the master branch of numpy/numpy in 2018 October +""" +# TODO: I don't know how to find the number of total pages +n_commits = 0 +for page in range(20): + repos = json.loads(requests.get('https://api.github.com/repos/numpy/numpy/commits', params={'page': page}).text) + commit_dates = [repo['commit']['author']['date'] for repo in repos] + n_commits += len([commit_date for commit_date in commit_dates if '2018-10' in commit_date]) +print(n_commits) -# Q2: Find out how many commits have been made to the master branch of numpy/numpy in 2018 October -repos = json.loads(requests.get('https://api.github.com/repos/numpy/numpy/commits').text) -commit_dates = [repo['commit']['author']['date'] for repo in repos] -print(len([commit_date for commit_date in commit_dates if '2018-10' in commit_date])) +""" +Q3: (cont'd after 2) Find out how many distinct users made those commits +""" - - -# print(type(requests.get('https://api.github.com/orgs/astropgh/repos').text)) -# print(len(type(repos))) +""" +Q4: List all the branch names in numpy/numpy +""" From 9cc107535b2ecff1166b1cc1fe26b8637f2c9e9e Mon Sep 17 00:00:00 2001 From: Kw Huang Date: Mon, 3 Dec 2018 15:38:49 -0500 Subject: [PATCH 3/4] done q4 --- task-10/task10.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/task-10/task10.py b/task-10/task10.py index 0f80312..661b325 100644 --- a/task-10/task10.py +++ b/task-10/task10.py @@ -5,20 +5,20 @@ """ Q1: Find out which user has submitted the most PRs in astropgh/learning-by-doing """ -repos = json.loads(requests.get('https://api.github.com/repos/astropgh/learning-by-doing/pulls').text) -prs_users = [repo['user']['login'] for repo in repos] -print(prs_users[np.argmax([prs_users.count(user) for user in prs_users])]) +# repos = json.loads(requests.get('https://api.github.com/repos/astropgh/learning-by-doing/pulls').text) +# prs_users = [repo['user']['login'] for repo in repos] +# print(prs_users[np.argmax([prs_users.count(user) for user in prs_users])]) """ Q2: Find out how many commits have been made to the master branch of numpy/numpy in 2018 October """ -# TODO: I don't know how to find the number of total pages -n_commits = 0 -for page in range(20): - repos = json.loads(requests.get('https://api.github.com/repos/numpy/numpy/commits', params={'page': page}).text) - commit_dates = [repo['commit']['author']['date'] for repo in repos] - n_commits += len([commit_date for commit_date in commit_dates if '2018-10' in commit_date]) -print(n_commits) +# # TODO: I don't know how to find the number of total pages +# n_commits = 0 +# for page in range(20): +# repos = json.loads(requests.get('https://api.github.com/repos/numpy/numpy/commits', params={'page': page}).text) +# commit_dates = [repo['commit']['author']['date'] for repo in repos] +# n_commits += len([commit_date for commit_date in commit_dates if '2018-10' in commit_date]) +# print(n_commits) """ Q3: (cont'd after 2) Find out how many distinct users made those commits @@ -28,3 +28,6 @@ """ Q4: List all the branch names in numpy/numpy """ +repos = json.loads(requests.get('https://api.github.com/repos/numpy/numpy/branches').text) +for repo in repos: + print(repo['name']) From cb308a1ef19db145e35a1aa6f73899eec8fd50fd Mon Sep 17 00:00:00 2001 From: Kw Huang Date: Tue, 11 Dec 2018 16:11:29 -0500 Subject: [PATCH 4/4] q1, q2, q4 done (q2 not good), q3 incomplete --- task-10/task10.py | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/task-10/task10.py b/task-10/task10.py index 661b325..87ca368 100644 --- a/task-10/task10.py +++ b/task-10/task10.py @@ -5,24 +5,39 @@ """ Q1: Find out which user has submitted the most PRs in astropgh/learning-by-doing """ -# repos = json.loads(requests.get('https://api.github.com/repos/astropgh/learning-by-doing/pulls').text) -# prs_users = [repo['user']['login'] for repo in repos] -# print(prs_users[np.argmax([prs_users.count(user) for user in prs_users])]) +repos = json.loads(requests.get('https://api.github.com/repos/astropgh/learning-by-doing/pulls').text) +prs_users = [repo['user']['login'] for repo in repos] +print(prs_users[np.argmax([prs_users.count(user) for user in prs_users])]) """ Q2: Find out how many commits have been made to the master branch of numpy/numpy in 2018 October """ -# # TODO: I don't know how to find the number of total pages -# n_commits = 0 -# for page in range(20): -# repos = json.loads(requests.get('https://api.github.com/repos/numpy/numpy/commits', params={'page': page}).text) -# commit_dates = [repo['commit']['author']['date'] for repo in repos] -# n_commits += len([commit_date for commit_date in commit_dates if '2018-10' in commit_date]) -# print(n_commits) +# TODO: I don't know how to find the number of total pages +n_commits = 0 +for page in range(20): + repos = json.loads(requests.get('https://api.github.com/repos/numpy/numpy/commits', params={'page': page}).text) + commit_dates = [repo['commit']['author']['date'] for repo in repos] + n_commits += len([commit_date for commit_date in commit_dates if '2018-10' in commit_date]) +print(n_commits) """ Q3: (cont'd after 2) Find out how many distinct users made those commits """ +# TODO: Not Done Yet.. +dis_names = [] +n_commits = 0 +for page in range(1,2): + repos = json.loads(requests.get('https://api.github.com/repos/numpy/numpy/commits', params={'page': page}).text) + commit_dates = [repo['commit']['author']['date'] for repo in repos] + commit_names = [repo['commit']['author']['name'] for repo in repos] + n_commits += len([commit_date for commit_date in commit_dates if '2018-10' in commit_date]) + for commit_date in commit_dates: + if '2018-10' in commit_date: + + + n_commits += len([commit_date for commit_date in commit_dates if '2018-10' in commit_date]) +print(n_commits) + """