-
Notifications
You must be signed in to change notification settings - Fork 0
/
usersrepos.js
86 lines (70 loc) · 2.15 KB
/
usersrepos.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var Github = require('github-api'),
Config = require('./config.js'),
d3 = require('d3'),
fs = require('fs');
var github = new Github({
username: Config.username,
password: Config.password,
auth: Config.basic
});
var data = fs.readFileSync('data/extra_users_list.tsv','utf8')
data = d3.tsv.parse(data)
var reposNumber = data.length-1,
//var reposNumber = 5,
reposCount = 0;
var output = [];
var writeFinalData = function(data){
var finalData = d3.tsv.format(data);
fs.writeFile('output/new_users_repos/output.tsv', finalData, function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
}
var getOrgsRepos = function(org){
var myorg = github.getUser();
myorg.userRepos(org, function(err, repos) {
if(err){
console.log(reposCount + '/' + reposNumber + ' ' + err)
reposCount = reposCount + 1;
if(reposCount < reposNumber){
getOrgsRepos(data[reposCount].user)
}else{
writeFinalData(output)
}
}else {
if(repos.length){
repos.forEach(function(d){
fs.writeFileSync('output/new_users_repos/' + org + '_' + d.name + '.json', JSON.stringify(d), 'utf8');
var elm = {
user: org,
name: d.name,
owner: d.owner.login,
description: d.description,
fork: d.fork,
language: d.language,
forks_count: d.forks_count,
stargazers_count: d.stargazers_count,
watchers_count: d.watchers_count,
size: d.size,
default_branch: d.default_branch,
open_issues_count: d.open_issues_count,
created_at: d.created_at,
updated_at: d.updated_at
}
output.push(elm);
console.log('---- ' + d.name)
})
}
console.log(reposCount + '/' + reposNumber + ' ' + org)
reposCount = reposCount + 1
if(reposCount < reposNumber){
getOrgsRepos(data[reposCount].user)
}else{
writeFinalData(output)
}
}
});
}
getOrgsRepos(data[reposCount].user)