Merge branch 'master' of https://github.com/sagidayan/SE-Hub into UI
This commit is contained in:
commit
7e3eeb104c
2 changed files with 51 additions and 8 deletions
|
@ -10,23 +10,31 @@ githubKeys = GitHubAPI_Keys()
|
||||||
def get_repo_general_info(repo_url):
|
def get_repo_general_info(repo_url):
|
||||||
url = 'https://api.github.com/repos/' + repo_url + '?client_id='+githubKeys.getId()+'&client_secret=' + githubKeys.getSecret()
|
url = 'https://api.github.com/repos/' + repo_url + '?client_id='+githubKeys.getId()+'&client_secret=' + githubKeys.getSecret()
|
||||||
req = requests.get(url)
|
req = requests.get(url)
|
||||||
|
if req.status_code == 202:
|
||||||
|
return None
|
||||||
return req.json()
|
return req.json()
|
||||||
|
|
||||||
|
|
||||||
def get_repo_stats(repo_url):
|
def get_repo_stats(repo_url):
|
||||||
url = 'https://api.github.com/repos/' + repo_url + '/stats/contributors' + '?client_id='+githubKeys.getId()+'&client_secret=' + githubKeys.getSecret()
|
url = 'https://api.github.com/repos/' + repo_url + '/stats/contributors' + '?client_id='+githubKeys.getId()+'&client_secret=' + githubKeys.getSecret()
|
||||||
req = requests.get(url)
|
req = requests.get(url)
|
||||||
|
if req.status_code == 202:
|
||||||
|
return None
|
||||||
return req.json()
|
return req.json()
|
||||||
|
|
||||||
|
|
||||||
def get_repo_issues(repo_url):
|
def get_repo_issues(repo_url):
|
||||||
url = 'https://api.github.com/repos/' + repo_url + '/issues' + '?client_id=' + githubKeys.getId() + '&client_secret=' + githubKeys.getSecret()
|
url = 'https://api.github.com/repos/' + repo_url + '/issues' + '?client_id=' + githubKeys.getId() + '&client_secret=' + githubKeys.getSecret()
|
||||||
req = requests.get(url)
|
req = requests.get(url)
|
||||||
|
if req.status_code == 202:
|
||||||
|
return None
|
||||||
return req.json()
|
return req.json()
|
||||||
|
|
||||||
def get_repo_weekly_commits(repo_url):
|
def get_repo_weekly_commits(repo_url):
|
||||||
url = 'https://api.github.com/repos/' + repo_url + '/stats/participation' + '?client_id=' + githubKeys.getId() + '&client_secret=' + githubKeys.getSecret()
|
url = 'https://api.github.com/repos/' + repo_url + '/stats/participation' + '?client_id=' + githubKeys.getId() + '&client_secret=' + githubKeys.getSecret()
|
||||||
req = requests.get(url)
|
req = requests.get(url)
|
||||||
|
if req.status_code == 202:
|
||||||
|
return None
|
||||||
week_obj = {}
|
week_obj = {}
|
||||||
week_obj['data'] = []
|
week_obj['data'] = []
|
||||||
try:
|
try:
|
||||||
|
@ -50,6 +58,8 @@ def get_repo_weekly_commits(repo_url):
|
||||||
def get_repo_commits(repo_url):
|
def get_repo_commits(repo_url):
|
||||||
url = 'https://api.github.com/repos/' + repo_url + '/commits' + '?client_id=' + githubKeys.getId() + '&client_secret=' + githubKeys.getSecret()
|
url = 'https://api.github.com/repos/' + repo_url + '/commits' + '?client_id=' + githubKeys.getId() + '&client_secret=' + githubKeys.getSecret()
|
||||||
req = requests.get(url)
|
req = requests.get(url)
|
||||||
|
if req.status_code == 202:
|
||||||
|
return None
|
||||||
return req.json()
|
return req.json()
|
||||||
|
|
||||||
def make_macro(stats, info, project_id):
|
def make_macro(stats, info, project_id):
|
||||||
|
@ -84,10 +94,43 @@ def get_issue_num(issues, user):
|
||||||
|
|
||||||
def get_github_data(repo_url, project_id):
|
def get_github_data(repo_url, project_id):
|
||||||
project_info = {'stats': {}}
|
project_info = {'stats': {}}
|
||||||
github_stats = get_repo_stats(repo_url) #first Call
|
info_stats = {'stats': False, 'info': False, 'issues': False, 'commits': False}
|
||||||
|
all_good = False
|
||||||
|
# github_stats = get_repo_stats(repo_url) #first Call
|
||||||
|
# if github_stats is not None:
|
||||||
|
# info_stats['stats'] = True
|
||||||
|
# project_info['info'] = get_repo_general_info(repo_url)
|
||||||
|
# if project_info['info'] is not None:
|
||||||
|
# info_stats['info'] = True
|
||||||
|
# issues = get_repo_issues(repo_url)
|
||||||
|
# if issues is not None:
|
||||||
|
# info_stats['issues'] = True
|
||||||
|
# weekly_commits = get_repo_weekly_commits(repo_url)
|
||||||
|
# if issues is not None:
|
||||||
|
# info_stats['commits'] = True
|
||||||
|
|
||||||
|
while not all_good:
|
||||||
|
if not info_stats['stats']:
|
||||||
|
github_stats = get_repo_stats(repo_url)
|
||||||
|
if github_stats is not None:
|
||||||
|
info_stats['stats'] = True
|
||||||
|
if not info_stats['info']:
|
||||||
project_info['info'] = get_repo_general_info(repo_url)
|
project_info['info'] = get_repo_general_info(repo_url)
|
||||||
|
if project_info['info'] is not None:
|
||||||
|
info_stats['info'] = True
|
||||||
|
if not info_stats['issues']:
|
||||||
issues = get_repo_issues(repo_url)
|
issues = get_repo_issues(repo_url)
|
||||||
|
if issues is not None:
|
||||||
|
info_stats['issues'] = True
|
||||||
|
if not info_stats['commits']:
|
||||||
weekly_commits = get_repo_weekly_commits(repo_url)
|
weekly_commits = get_repo_weekly_commits(repo_url)
|
||||||
|
if issues is not None:
|
||||||
|
info_stats['commits'] = True
|
||||||
|
all_good = True
|
||||||
|
for stat in info_stats:
|
||||||
|
if not info_stats[stat]:
|
||||||
|
all_good = False
|
||||||
|
|
||||||
github_stats = get_repo_stats(repo_url) #Second Call
|
github_stats = get_repo_stats(repo_url) #Second Call
|
||||||
project_info['stats']['macro'] = make_macro(github_stats, project_info['info'], project_id)
|
project_info['stats']['macro'] = make_macro(github_stats, project_info['info'], project_id)
|
||||||
project_info['stats']['micro'] = make_micro(github_stats, issues)
|
project_info['stats']['micro'] = make_micro(github_stats, issues)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<div class = "project">
|
<div class = "project">
|
||||||
<md-content layout-padding layout-margin>
|
<md-content layout-padding layout-margin>
|
||||||
<div layout = "row">
|
<div layout = "row">
|
||||||
<div ng-if="!project.logo_url || project.logo_url = ''">
|
<div ng-if="!project.logo_url || project.logo_url == ''">
|
||||||
<h1 layout-margin style="margin-left:15px"><i class="fa fa-cube"></i> {{project.projectName}}</h1>
|
<h1 layout-margin style="margin-left:15px"><i class="fa fa-cube"></i> {{project.projectName}}</h1>
|
||||||
</div ng-if="project.logo_url && project.logo_url != ''">
|
</div>
|
||||||
<div> <!-- ng-if = "{{project.logo_url}}"> -->
|
<div ng-if="project.logo_url && project.logo_url != ''"> <!-- ng-if = "{{project.logo_url}}"> -->
|
||||||
<div flex = "10" layout='row'>
|
<div flex = "10" layout='row'>
|
||||||
<div>
|
<div>
|
||||||
<img ng-src="{{project.logo_url}}" class = "md-avatar">
|
<img ng-src="{{project.logo_url}}" class = "md-avatar">
|
||||||
|
|
Loading…
Reference in a new issue