From 5b9504ea453a132216b2587f73bc61a83d537592 Mon Sep 17 00:00:00 2001 From: ouyangwuhai <303423249@qq.com> Date: Wed, 24 Apr 2019 00:10:01 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0statistics=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=B0=81=E8=A3=85=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/repositories/statistics.py | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 api/repositories/statistics.py diff --git a/api/repositories/statistics.py b/api/repositories/statistics.py new file mode 100644 index 0000000..ccda15a --- /dev/null +++ b/api/repositories/statistics.py @@ -0,0 +1,35 @@ +from core.rest_client import RestClient + +class Statistics(RestClient): + def __init__(self, api_root_url, **kwargs): + super(Statistics, self).__init__(api_root_url, **kwargs) + + def get_contributors_list(self,owner,repo,**kwargs): + """ + https://developer.github.com/v3/repos/statistics/#get-contributors-list-with-additions-deletions-and-commit-counts + """ + return self.get("/repos/{}/{}/stats/contributors".format(owner,repo),**kwargs) + + def get_last_year_commit(self,owner,repo,**kwargs): + """ + https://developer.github.com/v3/repos/statistics/#get-the-last-year-of-commit-activity-data + """ + return self.get("/repos/{}/{}/stats/commit_activity".format(owner,repo),**kwargs) + + def get_number_of_additions_deletions(self,owner,repo,**kwargs): + """ + https://developer.github.com/v3/repos/statistics/#get-the-number-of-additions-and-deletions-per-week + """ + return self.get("/repos/{}/{}/stats/code_frequency".format(owner,repo),**kwargs) + + def get_weekly_commit_count(self,owner,repo,**kwargs): + """ + https://developer.github.com/v3/repos/statistics/#get-the-weekly-commit-count-for-the-repository-owner-and-everyone-else + """ + return self.get("/repos/{}/{}/stats/participation".format(owner,repo),**kwargs) + + def get_numbers_commits_hour(self,owner,repo,**kwargs): + """ + https://developer.github.com/v3/repos/statistics/#get-the-number-of-commits-per-hour-in-each-day + """ + self.get("/repos/{}/{}/stats/punch_card".format(owner,repo),**kwargs) From b164332579ee66414e767becbcdb970ff6bc00c8 Mon Sep 17 00:00:00 2001 From: ouyangwuhai <303423249@qq.com> Date: Thu, 25 Apr 2019 23:05:56 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0statuses=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=B0=81=E8=A3=85=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/repositories/statuses.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 api/repositories/statuses.py diff --git a/api/repositories/statuses.py b/api/repositories/statuses.py new file mode 100644 index 0000000..bafc337 --- /dev/null +++ b/api/repositories/statuses.py @@ -0,0 +1,23 @@ +from core.rest_client import RestClient + +class Statuses(RestClient): + def __init__(self, api_root_url, **kwargs): + super(Statuses, self).__init__(api_root_url, **kwargs) + + def create_a_status(self,owner,repo,sha,**kwargs): + """ + https://developer.github.com/v3/repos/statuses/#create-a-status + """ + return self.post("/repos/{}/{}/statuses/{}".format(owner,repo,sha),**kwargs) + + def list_statuses_for_specific_ref(self,owner,repo,ref,**kwargs): + """ + https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref + """ + return self.get("/repos/{}/{}/commits/{}/statuses".format(owner,repo,ref),**kwargs) + + def get_combined_status_for_specific_ref(self,owner,repo,ref,**kwargs): + """ + https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref + """ + return self.get("/repos/{}/{}/commits/{}/status".format(owner,repo,ref),**kwargs) \ No newline at end of file From 1a10d9c2c86a3748e206025ffc463ccf9d22b5d6 Mon Sep 17 00:00:00 2001 From: ouyangwuhai <303423249@qq.com> Date: Thu, 25 Apr 2019 23:23:52 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0statistics=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=B0=81=E8=A3=85=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/repositories/statistics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/repositories/statistics.py b/api/repositories/statistics.py index ccda15a..91d4581 100644 --- a/api/repositories/statistics.py +++ b/api/repositories/statistics.py @@ -32,4 +32,4 @@ def get_numbers_commits_hour(self,owner,repo,**kwargs): """ https://developer.github.com/v3/repos/statistics/#get-the-number-of-commits-per-hour-in-each-day """ - self.get("/repos/{}/{}/stats/punch_card".format(owner,repo),**kwargs) + return self.get("/repos/{}/{}/stats/punch_card".format(owner,repo),**kwargs)