From 6bc9420038a9e07db649a78804e506f79f63dc03 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 29 Jun 2015 17:56:58 +0300 Subject: [PATCH] API_Github Conecctor finished --- SE_API/GitHub_API_Connector.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/SE_API/GitHub_API_Connector.py b/SE_API/GitHub_API_Connector.py index 729f897..33c59b8 100644 --- a/SE_API/GitHub_API_Connector.py +++ b/SE_API/GitHub_API_Connector.py @@ -36,15 +36,22 @@ def make_macro(stats, info): return macro -# def make_micro(stats, info): -# micro = {'labels': [], 'data': [[]], 'series': []} -# micro['labels'].append('Commits') -# micro['labels'].append('Open Issues') -# for stat in stats: -# micro['data'][0][0] += stat['total'] -# micro['data'].append(info['open_issues']) -# -# return micro +def make_micro(stats, issues): + micro = {'labels': [], 'data': [], 'series': []} + micro['labels'].append('Commits') + micro['labels'].append('Open Issues') + for stat in stats: + micro['series'].append(stat['author']['login']) + micro['data'].append([stat['total'], get_issue_num(issues, stat['author']['login'])]) + + return micro + +def get_issue_num(issues, user): + numOfIssues = 0 + for issue in issues: + if issue['user']['login'] == user: + numOfIssues += 1 + return numOfIssues def get_github_data(repo_url): project_info = {'stats': {}} @@ -54,7 +61,7 @@ def get_github_data(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']) - + project_info['stats']['micro'] = make_micro(github_stats, issues) project_info['stats']['weekly_commits'] = weekly_commits project_info['issues'] = issues