Skip to content

增加statistics接口封装文件 #273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions api/repositories/statistics.py
Original file line number Diff line number Diff line change
@@ -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
"""
return self.get("/repos/{}/{}/stats/punch_card".format(owner,repo),**kwargs)
23 changes: 23 additions & 0 deletions api/repositories/statuses.py
Original file line number Diff line number Diff line change
@@ -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)