浏览代码

Merging branches

David Leonard 10 年之前
父节点
当前提交
39041104c7
共有 2 个文件被更改,包括 32 次插入2 次删除
  1. 29 1
      hackathon_starter/hackathon/scripts/github.py
  2. 3 1
      hackathon_starter/hackathon/views.py

+ 29 - 1
hackathon_starter/hackathon/scripts/github.py

@@ -11,7 +11,11 @@ import simplejson as json
 ########################
 
 API_BASE_URL = 'https://api.github.com/'
-API_USERS_URL = API_BASE_URL + 'users/DrkSephy'
+API_USERS_URL = API_BASE_URL + 'users/DrkSephy' + '?client_id=2404a1e21aebd902f6db' + '&client_secret=3da44769d4b7c9465fa4c812669148a163607c23'
+
+# Endpoint to get statistics in a repository
+# https://api.github.com/repos/DrkSephy/WaterEmblem/stats/contributors
+# https://api.github.com/repos/:user/:repo/stats/contributors
 
 def getUserData():
 	req = requests.get(API_USERS_URL)
@@ -29,7 +33,31 @@ def getUserData():
 		userData['followers'] = data['followers']
 		userData['following'] = data['following']
 	parsedData.append(userData)
+
 	return parsedData
 	
+
+def getUserRepositories():
+	pageNumber = 1
+	firstUrl = API_USERS_URL + '/repos' + '?page=' + str(pageNumber) + '&client_id=2404a1e21aebd902f6db' + '&client_secret=3da44769d4b7c9465fa4c812669148a163607c23'
+	urls = []
+	urls.append(firstUrl)
+	jsonList = []
+	repositories = []
+	while True:
+		req = requests.get(API_USERS_URL + '/repos' + '?page=' + str(pageNumber) + '&client_id=2404a1e21aebd902f6db' + '&client_secret=3da44769d4b7c9465fa4c812669148a163607c23')
+		jsonList.append(json.loads(req.content))
+		for data in jsonList:
+			for datum in data:
+				if len(datum) < 30:
+					print 'hello'
+					break
+				elif len(datum) >= 30:
+					pageNumber += 1
+					urls.append(API_USERS_URL + '/repos' + '?page=' + str(pageNumber) + '&client_id=2404a1e21aebd902f6db' + '&client_secret=3da44769d4b7c9465fa4c812669148a163607c23')
+	print urls
+	
+	return repositories
+
 	
 	

+ 3 - 1
hackathon_starter/hackathon/views.py

@@ -5,7 +5,7 @@ from django.template import RequestContext, loader
 from django.contrib.auth import authenticate, login
 from django.http import HttpResponse, HttpResponseRedirect
 from scripts.steam import gamesPulling, steamIDPulling 
-from scripts.github import getUserData
+from scripts.github import getUserData, getUserRepositories
 
 
 def index(request):
@@ -118,6 +118,8 @@ def steam(request):
 
 def github(request):
     userData = getUserData()
+    #repositories = getUserRepositories()
+    #print repositories
     return render(request, 'hackathon/github.html', { 'data': userData })
 
 def tumblr(request):