{"action":"created","comment":{"url":"https://api.github.com/repos/OSDG-IIITH/contributors/pulls/comments/36259114","id":36259114,"diff_hunk":"@@ -0,0 +1,118 @@\n+import json, requests\n+import simplejson\n+import json\n+\n+filters=['easy','medium','hard','bug']\n+stats=['additions','deletions','commits']\n+scoring=dict(zip(filters+stats,[20,50,100,10]+[1,1,5]))\n+users={}\n+def init_user(login):\n+    users[login]=dict(zip(filters+stats,len(filters+stats)*[0]))\n+\n+def req(get,params={}):\n+    \"\"\"Function to send HTTP Requests\"\"\"\n+    params['access_token']='d0fec873c0a68b8e8b29b2403914a41f59479dc5'\n+    api_host=\"https://api.github.com\"\n+    url=api_host+get\n+    resp = requests.get(url=url, params=params)\n+\n+    try:\n+        data = json.loads(resp.text)\n+    except:\n+        data=[]\n+    return data\n+\n+\n+def get_repos(org):\n+    \"\"\"Returns Repos under an organization\"\"\"\n+    url='/orgs/'+org+'/repos'\n+    repo_list=req(url)\n+    repos=[]\n+    for repo in repo_list:\n+        repos.append(repo[\"name\"])\n+    return repos\n+\n+def get_repo_issues(repo,org,closed=True):\n+    \"\"\"Returns a list of issues(closed issues, by default) under a repository\"\"\"\n+    url='/repos/'+org+'/'+repo+'/issues'\n+    params={'state':'closed'} if closed else {}\n+    issues=req(url,params)\n+    return issues\n+\n+\n+\n+def filter_issues(issue_list):\n+    \"\"\"Returns a list of issues which have specific labels\"\"\"\n+\n+    filt_issues=[]\n+    for issue in issue_list:\n+        labels=issue['labels']\n+        for label in labels:\n+            lname=label['name'].lower()\n+            if lname in filters:\n+                filt_issues.append(issue)\n+\n+    return filt_issues\n+\n+def update_issue_count(issue_list):\n+    for issue in issue_list:\n+        if(issue['assignee']):\n+            assignee=issue['assignee']['login']\n+            if not users.has_key(assignee):\n+                init_user(assignee)\n+        else:\n+            #no points if no assignee\n+            continue\n+        labels=issue['labels']\n+        for label in labels:\n+            lname=label['name'].lower()\n+            if(lname in filters):\n+                users[assignee][lname]+=1\n+\n+\n+def score(count):\n+\n+    #defaut score is 10\n+    ans=10\n+\n+\n+    for lbl,ct in count.iteritems():\n+            ans+=scoring[lbl]*ct\n+\n+    return ans\n+\n+def update_contributors(repo,org):\n+    \"\"\"Updates list of contributors with additions deletions, and commit counts\"\"\"\n+    url='/repos/'+org+'/'+repo+'/stats/contributors'\n+    contribs=req(url)\n+    for contrib in contribs:\n+            login=contrib['author']['login']\n+            if not users.has_key(login):\n+               init_user(login)\n+            for week in contrib['weeks']:\n+                users[login]['additions']+=week['a']\n+                users[login]['deletions']+=week['d']\n+                users[login]['commits']+=week['c']\n+\n+\n+\n+if __name__ == \"__main__\":\n+    org=\"OSDG-IIITH\"","path":"ranker/labelled_ranker.py","position":100,"original_position":100,"commit_id":"f9212c0a5c5988a1bd9821b6845b8a4f255c0aef","original_commit_id":"f9212c0a5c5988a1bd9821b6845b8a4f255c0aef","user":{"login":"bitgeeky","id":4486964,"avatar_url":"https://avatars.githubusercontent.com/u/4486964?v=3","gravatar_id":"","url":"https://api.github.com/users/bitgeeky","html_url":"https://github.com/bitgeeky","followers_url":"https://api.github.com/users/bitgeeky/followers","following_url":"https://api.github.com/users/bitgeeky/following{/other_user}","gists_url":"https://api.github.com/users/bitgeeky/gists{/gist_id}","starred_url":"https://api.github.com/users/bitgeeky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitgeeky/subscriptions","organizations_url":"https://api.github.com/users/bitgeeky/orgs","repos_url":"https://api.github.com/users/bitgeeky/repos","events_url":"https://api.github.com/users/bitgeeky/events{/privacy}","received_events_url":"https://api.github.com/users/bitgeeky/received_events","type":"User","site_admin":false},"body":"Use an environment variable or pass as an argument so that the project can be used in general by anyone.","created_at":"2015-08-05T00:34:11Z","updated_at":"2015-08-05T00:34:11Z","html_url":"https://github.com/OSDG-IIITH/contributors/pull/11#discussion_r36259114","pull_request_url":"https://api.github.com/repos/OSDG-IIITH/contributors/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/OSDG-IIITH/contributors/pulls/comments/36259114"},"html":{"href":"https://github.com/OSDG-IIITH/contributors/pull/11#discussion_r36259114"},"pull_request":{"href":"https://api.github.com/repos/OSDG-IIITH/contributors/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/OSDG-IIITH/contributors/pulls/11","id":41400403,"html_url":"https://github.com/OSDG-IIITH/contributors/pull/11","diff_url":"https://github.com/OSDG-IIITH/contributors/pull/11.diff","patch_url":"https://github.com/OSDG-IIITH/contributors/pull/11.patch","issue_url":"https://api.github.com/repos/OSDG-IIITH/contributors/issues/11","number":11,"state":"open","locked":false,"title":"Script and sample data for leaderboard","user":{"login":"bhaktipriya","id":11070390,"avatar_url":"https://avatars.githubusercontent.com/u/11070390?v=3","gravatar_id":"","url":"https://api.github.com/users/bhaktipriya","html_url":"https://github.com/bhaktipriya","followers_url":"https://api.github.com/users/bhaktipriya/followers","following_url":"https://api.github.com/users/bhaktipriya/following{/other_user}","gists_url":"https://api.github.com/users/bhaktipriya/gists{/gist_id}","starred_url":"https://api.github.com/users/bhaktipriya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhaktipriya/subscriptions","organizations_url":"https://api.github.com/users/bhaktipriya/orgs","repos_url":"https://api.github.com/users/bhaktipriya/repos","events_url":"https://api.github.com/users/bhaktipriya/events{/privacy}","received_events_url":"https://api.github.com/users/bhaktipriya/received_events","type":"User","site_admin":false},"body":"The Python script evaluates users based on the number and difficulty of issues solved and on the basis of additions, deletions and commits.\r\n\r\nAll data is in JSON format. ","created_at":"2015-08-01T11:17:08Z","updated_at":"2015-08-05T00:34:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4693bbe50b3a1fbe2a341baa9cc4c35b6c4f8a0f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OSDG-IIITH/contributors/pulls/11/commits","review_comments_url":"https://api.github.com/repos/OSDG-IIITH/contributors/pulls/11/comments","review_comment_url":"https://api.github.com/repos/OSDG-IIITH/contributors/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OSDG-IIITH/contributors/issues/11/comments","statuses_url":"https://api.github.com/repos/OSDG-IIITH/contributors/statuses/f9212c0a5c5988a1bd9821b6845b8a4f255c0aef","head":{"label":"bhaktipriya:master","ref":"master","sha":"f9212c0a5c5988a1bd9821b6845b8a4f255c0aef","user":{"login":"bhaktipriya","id":11070390,"avatar_url":"https://avatars.githubusercontent.com/u/11070390?v=3","gravatar_id":"","url":"https://api.github.com/users/bhaktipriya","html_url":"https://github.com/bhaktipriya","followers_url":"https://api.github.com/users/bhaktipriya/followers","following_url":"https://api.github.com/users/bhaktipriya/following{/other_user}","gists_url":"https://api.github.com/users/bhaktipriya/gists{/gist_id}","starred_url":"https://api.github.com/users/bhaktipriya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhaktipriya/subscriptions","organizations_url":"https://api.github.com/users/bhaktipriya/orgs","repos_url":"https://api.github.com/users/bhaktipriya/repos","events_url":"https://api.github.com/users/bhaktipriya/events{/privacy}","received_events_url":"https://api.github.com/users/bhaktipriya/received_events","type":"User","site_admin":false},"repo":{"id":39004179,"name":"osdg-leaderboard","full_name":"bhaktipriya/osdg-leaderboard","owner":{"login":"bhaktipriya","id":11070390,"avatar_url":"https://avatars.githubusercontent.com/u/11070390?v=3","gravatar_id":"","url":"https://api.github.com/users/bhaktipriya","html_url":"https://github.com/bhaktipriya","followers_url":"https://api.github.com/users/bhaktipriya/followers","following_url":"https://api.github.com/users/bhaktipriya/following{/other_user}","gists_url":"https://api.github.com/users/bhaktipriya/gists{/gist_id}","starred_url":"https://api.github.com/users/bhaktipriya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhaktipriya/subscriptions","organizations_url":"https://api.github.com/users/bhaktipriya/orgs","repos_url":"https://api.github.com/users/bhaktipriya/repos","events_url":"https://api.github.com/users/bhaktipriya/events{/privacy}","received_events_url":"https://api.github.com/users/bhaktipriya/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bhaktipriya/osdg-leaderboard","description":"OSDG Ranker. A ranking of people based on the amount of Open Source work they've done.","fork":true,"url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard","forks_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/forks","keys_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/teams","hooks_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/hooks","issue_events_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/issues/events{/number}","events_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/events","assignees_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/assignees{/user}","branches_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/branches{/branch}","tags_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/tags","blobs_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/git/refs{/sha}","trees_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/statuses/{sha}","languages_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/languages","stargazers_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/stargazers","contributors_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/contributors","subscribers_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/subscribers","subscription_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/subscription","commits_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/commits{/sha}","git_commits_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/git/commits{/sha}","comments_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/comments{/number}","issue_comment_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/issues/comments{/number}","contents_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/contents/{+path}","compare_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/merges","archive_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/downloads","issues_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/issues{/number}","pulls_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/pulls{/number}","milestones_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/milestones{/number}","notifications_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/labels{/name}","releases_url":"https://api.github.com/repos/bhaktipriya/osdg-leaderboard/releases{/id}","created_at":"2015-07-13T09:51:42Z","updated_at":"2015-08-04T13:58:30Z","pushed_at":"2015-08-04T16:28:55Z","git_url":"git://github.com/bhaktipriya/osdg-leaderboard.git","ssh_url":"git@github.com:bhaktipriya/osdg-leaderboard.git","clone_url":"https://github.com/bhaktipriya/osdg-leaderboard.git","svn_url":"https://github.com/bhaktipriya/osdg-leaderboard","homepage":null,"size":163,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"OSDG-IIITH:master","ref":"master","sha":"b1f4f7bb9973bd55ca3c94c2ec81c22e128af67e","user":{"login":"OSDG-IIITH","id":2324352,"avatar_url":"https://avatars.githubusercontent.com/u/2324352?v=3","gravatar_id":"","url":"https://api.github.com/users/OSDG-IIITH","html_url":"https://github.com/OSDG-IIITH","followers_url":"https://api.github.com/users/OSDG-IIITH/followers","following_url":"https://api.github.com/users/OSDG-IIITH/following{/other_user}","gists_url":"https://api.github.com/users/OSDG-IIITH/gists{/gist_id}","starred_url":"https://api.github.com/users/OSDG-IIITH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OSDG-IIITH/subscriptions","organizations_url":"https://api.github.com/users/OSDG-IIITH/orgs","repos_url":"https://api.github.com/users/OSDG-IIITH/repos","events_url":"https://api.github.com/users/OSDG-IIITH/events{/privacy}","received_events_url":"https://api.github.com/users/OSDG-IIITH/received_events","type":"Organization","site_admin":false},"repo":{"id":38997578,"name":"contributors","full_name":"OSDG-IIITH/contributors","owner":{"login":"OSDG-IIITH","id":2324352,"avatar_url":"https://avatars.githubusercontent.com/u/2324352?v=3","gravatar_id":"","url":"https://api.github.com/users/OSDG-IIITH","html_url":"https://github.com/OSDG-IIITH","followers_url":"https://api.github.com/users/OSDG-IIITH/followers","following_url":"https://api.github.com/users/OSDG-IIITH/following{/other_user}","gists_url":"https://api.github.com/users/OSDG-IIITH/gists{/gist_id}","starred_url":"https://api.github.com/users/OSDG-IIITH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OSDG-IIITH/subscriptions","organizations_url":"https://api.github.com/users/OSDG-IIITH/orgs","repos_url":"https://api.github.com/users/OSDG-IIITH/repos","events_url":"https://api.github.com/users/OSDG-IIITH/events{/privacy}","received_events_url":"https://api.github.com/users/OSDG-IIITH/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OSDG-IIITH/contributors","description":"OSDG Ranker. A ranking of people based on the amount of Open Source work they've done.","fork":false,"url":"https://api.github.com/repos/OSDG-IIITH/contributors","forks_url":"https://api.github.com/repos/OSDG-IIITH/contributors/forks","keys_url":"https://api.github.com/repos/OSDG-IIITH/contributors/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OSDG-IIITH/contributors/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OSDG-IIITH/contributors/teams","hooks_url":"https://api.github.com/repos/OSDG-IIITH/contributors/hooks","issue_events_url":"https://api.github.com/repos/OSDG-IIITH/contributors/issues/events{/number}","events_url":"https://api.github.com/repos/OSDG-IIITH/contributors/events","assignees_url":"https://api.github.com/repos/OSDG-IIITH/contributors/assignees{/user}","branches_url":"https://api.github.com/repos/OSDG-IIITH/contributors/branches{/branch}","tags_url":"https://api.github.com/repos/OSDG-IIITH/contributors/tags","blobs_url":"https://api.github.com/repos/OSDG-IIITH/contributors/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OSDG-IIITH/contributors/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OSDG-IIITH/contributors/git/refs{/sha}","trees_url":"https://api.github.com/repos/OSDG-IIITH/contributors/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OSDG-IIITH/contributors/statuses/{sha}","languages_url":"https://api.github.com/repos/OSDG-IIITH/contributors/languages","stargazers_url":"https://api.github.com/repos/OSDG-IIITH/contributors/stargazers","contributors_url":"https://api.github.com/repos/OSDG-IIITH/contributors/contributors","subscribers_url":"https://api.github.com/repos/OSDG-IIITH/contributors/subscribers","subscription_url":"https://api.github.com/repos/OSDG-IIITH/contributors/subscription","commits_url":"https://api.github.com/repos/OSDG-IIITH/contributors/commits{/sha}","git_commits_url":"https://api.github.com/repos/OSDG-IIITH/contributors/git/commits{/sha}","comments_url":"https://api.github.com/repos/OSDG-IIITH/contributors/comments{/number}","issue_comment_url":"https://api.github.com/repos/OSDG-IIITH/contributors/issues/comments{/number}","contents_url":"https://api.github.com/repos/OSDG-IIITH/contributors/contents/{+path}","compare_url":"https://api.github.com/repos/OSDG-IIITH/contributors/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OSDG-IIITH/contributors/merges","archive_url":"https://api.github.com/repos/OSDG-IIITH/contributors/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OSDG-IIITH/contributors/downloads","issues_url":"https://api.github.com/repos/OSDG-IIITH/contributors/issues{/number}","pulls_url":"https://api.github.com/repos/OSDG-IIITH/contributors/pulls{/number}","milestones_url":"https://api.github.com/repos/OSDG-IIITH/contributors/milestones{/number}","notifications_url":"https://api.github.com/repos/OSDG-IIITH/contributors/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OSDG-IIITH/contributors/labels{/name}","releases_url":"https://api.github.com/repos/OSDG-IIITH/contributors/releases{/id}","created_at":"2015-07-13T07:28:37Z","updated_at":"2015-07-14T18:32:28Z","pushed_at":"2015-08-04T16:28:55Z","git_url":"git://github.com/OSDG-IIITH/contributors.git","ssh_url":"git@github.com:OSDG-IIITH/contributors.git","clone_url":"https://github.com/OSDG-IIITH/contributors.git","svn_url":"https://github.com/OSDG-IIITH/contributors","homepage":null,"size":239,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OSDG-IIITH/contributors/pulls/11"},"html":{"href":"https://github.com/OSDG-IIITH/contributors/pull/11"},"issue":{"href":"https://api.github.com/repos/OSDG-IIITH/contributors/issues/11"},"comments":{"href":"https://api.github.com/repos/OSDG-IIITH/contributors/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/OSDG-IIITH/contributors/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/OSDG-IIITH/contributors/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OSDG-IIITH/contributors/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/OSDG-IIITH/contributors/statuses/f9212c0a5c5988a1bd9821b6845b8a4f255c0aef"}}}}