From 3db75de9b0150e97a7674d32faf9bbce52b5150f Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 29 Jun 2015 16:38:39 +0300 Subject: [PATCH] Sorted Project imfo API --- SE_API/GitHub_API_Connector.py | 40 ++++++++++++++++--- templates/js/controllers/profileController.js | 6 +-- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/SE_API/GitHub_API_Connector.py b/SE_API/GitHub_API_Connector.py index dbafa03..b93ef2c 100644 --- a/SE_API/GitHub_API_Connector.py +++ b/SE_API/GitHub_API_Connector.py @@ -21,13 +21,41 @@ def get_repo_issues(repo_url): req = requests.get(url) return req.json() +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() + req = requests.get(url) + return req.json()['all'] + +def make_macro(stats, info): + macro = {'labels': [], 'data': [0]} + macro['labels'].append('Commits') + macro['labels'].append('Open Issues') + for stat in stats: + macro['data'][0] += stat['total'] + macro['data'].append(info['open_issues']) + + return macro + +def make_micro(stats, info): + micro = {'labels': [], 'data': [0], 'series': []} + micro['labels'].append('Commits') + micro['labels'].append('Open Issues') + for stat in stats: + micro['data'][0] += stat['total'] + micro['data'].append(info['open_issues']) + + return micro def get_github_data(repo_url): - project_info = {'stats': None, 'issues': None, 'info': None} - - project_info['stats'] = get_repo_stats(repo_url) #first Call + project_info = {'stats': {}} + github_stats = get_repo_stats(repo_url) #first Call project_info['info'] = get_repo_general_info(repo_url) - project_info['issues'] = get_repo_issues(repo_url) - project_info['stats'] = get_repo_stats(repo_url) #Second Call + issues = get_repo_issues(repo_url) + weekly_commits = get_repo_weekly_commits(repo_url) + github_stats = get_repo_stats(repo_url) #Second Call + project_info['stats']['macro'] = make_macro(github_stats, project_info['info']) - return project_info \ No newline at end of file + project_info['stats']['weekly_commits'] = weekly_commits + project_info['issues'] = issues + + return project_info diff --git a/templates/js/controllers/profileController.js b/templates/js/controllers/profileController.js index 208b08a..c18d9cb 100644 --- a/templates/js/controllers/profileController.js +++ b/templates/js/controllers/profileController.js @@ -89,11 +89,11 @@ angular.module('SeHub') $scope.labels = ['Commits', 'Issues Assigned', 'Messages', 'Open Tasks']; - $scope.series = ['Project A', 'Project B']; + //$scope.series = ['Project A', 'Project B']; $scope.data = [ - [54, 3, 15, 3], - [28, 48, 40, 3] + [54, 3, 15, 3]//, + //[28, 48, 40, 3] ]; $scope.isUser = $scope.$parent.user.id.toString() /*The Actual User*/ === $routeParams.id /*The Profile User*/;