-
Notifications
You must be signed in to change notification settings - Fork 0
/
users.js
62 lines (49 loc) · 1.41 KB
/
users.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
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/users_list.tsv','utf8')
data = d3.tsv.parse(data)
var usersNumber = data.length-1,
//var usersNumber = 5,
usersCount = 0;
//var output = [];
// var writeFinalData = function(data){
// var finalData = d3.tsv.format(data);
// fs.writeFile('output/users/output.tsv', finalData, function(err) {
// if(err) {
// return console.log(err);
// }
// console.log("The file was saved!");
// });
//
// }
var getUser = function(user){
var myuser = github.getUser();
myuser.show(user, function(err, userData) {
if(err){
console.log(usersCount + '/' + usersNumber + ' ' + err)
usersCount = usersCount + 1;
if(usersCount < usersNumber){
getUser(data[usersCount].user)
}else{
console.log('finished');
}
}else {
fs.writeFileSync('output/users/' + user + '.json', JSON.stringify(userData), 'utf8');
console.log(usersCount + '/' + usersNumber + ' ' + userData.login)
usersCount = usersCount + 1
if(usersCount < usersNumber){
getUser(data[usersCount].user)
}else{
console.log('finished');
}
}
});
}
getUser(data[usersCount].user)