-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtotalRepos.py
More file actions
41 lines (35 loc) · 895 Bytes
/
totalRepos.py
File metadata and controls
41 lines (35 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pymongo, json
users = {}
totals = {}
client = pymongo.MongoClient(host='da0.eecs.utk.edu')
db = client['bitbucket']
commits = db['commits']
f = open('data/repList.data', 'r')
replist = json.loads(f.read())
iterator = commits.find({})
for result in iterator:
try:
for commit in result['values']:
username = ''
reponame = ''
try:
username = commit['author']['user']['username']
reponame = commit['repository']['full_name']
except KeyError:
pass
if username != '' and reponame != '':
try:
users[username]
except KeyError:
users[username] = {
'count' : 0,
'repos' : []
}
if not reponame in users[username]['repos']:
users[username]['count'] += 1
users[username]['repos'].append(reponame)
except KeyError:
pass
for username in users:
totals[username] = users[username]['count']
print json.dumps(totals)