-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhandleOrg.js
More file actions
79 lines (67 loc) · 2.47 KB
/
handleOrg.js
File metadata and controls
79 lines (67 loc) · 2.47 KB
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
const getRepos = require("./getRepos.js");
const getCommitHistory = require("./getCommitHistory.js");
const getForkHistory = require("./getForkHistory.js");
const getStarHistory = require("./getStarHistory.js");
const getIssueHistory = require("./getIssueHistory.js");
const getContributors = require("./getContributors.js");
async function handleRepo(repo) {
var repo_data = new Map();
// basic info
repo_data.set("watch", repo.watchers_count);
repo_data.set("star", repo.stargazers_count);
repo_data.set("fork", repo.forks_count);
repo_data.set("open_issue_pr", repo.open_issues_count);
var ret = await getCommitHistory.getCommitHistory(repo.owner.login, repo.name);
if (ret != undefined) {
repo_data.set("commit_history", ret[0]);
repo_data.set("acc_commit_history", ret[1]);
}
ret = await getForkHistory.getForkHistory(repo.owner.login, repo.name);
if (ret != undefined) {
repo_data.set("fork_history", ret[0]);
repo_data.set("acc_fork_history", ret[1]);
}
ret = await getStarHistory.getStarHistory(repo.owner.login, repo.name);
if (ret != undefined) {
repo_data.set("star_history", ret[0]);
repo_data.set("acc_star_history", ret[1]);
}
ret = await getIssueHistory.getIssueHistory(repo.owner.login, repo.name);
if (ret != undefined) {
repo_data.set("issue", ret[0]);
repo_data.set("open_issue", ret[1]);
repo_data.set("pull_request", ret[2]);
repo_data.set("open_pull_request", ret[3]);
repo_data.set("issue_history", ret[4]);
repo_data.set("acc_issue_history", ret[5]);
repo_data.set("pull_request_history", ret[6]);
repo_data.set("acc_pull_request_history", ret[7]);
}
ret = await getContributors.getContributors(repo.owner.login, repo.name);
if (ret != undefined) {
repo_data.set("contributors_count", ret.length);
repo_data.set("contributors_list", ret);
}
return repo_data;
}
async function handleOrg(org_name) {
console.info("handleOrg: " + org_name);
//var promises = [];
var org_data = new Map();
var repo_list = await getRepos.getRepos(org_name);
if (repo_list != undefined) {
for (let repo of repo_list) {
/*promises.push(
handleRepo(repo).then((repo_data) => {
org_data.set(repo.name, repo_data);
})
);*/
console.info("handleRepo: " + repo.name);
var repo_data = await handleRepo(repo);
org_data.set(repo.name, repo_data);
}
}
//await Promise.all(promises);
return org_data;
}
module.exports.handleOrg = handleOrg;