forked from dkurt/openvino_practice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
111 lines (96 loc) · 3.16 KB
/
index.html
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<html>
<head>
<style>
table {
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
text-align: center;
padding: 5px;
}
</style>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type='text/javascript'>
var prefix = "https://api.github.com/repos/dkurt/openvino_practice";
var users = new Map();
function renderTable() {
// Get a list of all the modules
$.ajax({
url: prefix + "/contents/modules?recursive=0",
dataType: 'json'
}).done(function(modules) {
var table = document.getElementById("results");
// Sort names by leading number
modules.sort(function(a, b) {
return a.name.localeCompare(b.name, undefined, {numeric: true, sensitivity: 'base'})
});
var header = table.insertRow();
header.insertCell(0).innerHTML = "User name";
modules.forEach(function(entry) {
header.insertCell().innerHTML = "<a href=" + entry.html_url + ">" + entry.name + "</a>";
});
users.forEach((progress, userId) => {
var row = table.insertRow();
row.insertCell().innerHTML = "<a href=https://github.com/" + userId + ">" + userId + "</a>";
modules.forEach(function(entry) {
var data = progress.get(entry.name);
var cell = row.insertCell();
if (data) {
var html = "<a href=" +data[0] + "><img src='https://img.shields.io/badge/";
if (data[1]) {
html += "-accepted-4BC51D";
} else {
html += "-in progress-red";
}
cell.innerHTML = html + "?style=plastic'></a>";
}
});
});
});
}
var pageId = 1;
// Get a list of all pull requests
function fetchPullRequests() {
$.ajax({
// Maximum number of pull requests per page is 100
url: prefix + "/pulls?per_page=100&sort=created&page=" + pageId,
dataType: 'json'
}).done(function(res) {
res.forEach(function(entry) {
var userId = entry.user.login;
if (!users.has(userId)) {
users.set(userId, new Map());
}
// Check for labels. Might be just module label or module label + approve
var moduleNames = [];
var isAccepted = false;
entry.labels.forEach(function(label) {
var matches = label.name.match(/module: (.*)/);
if (matches) {
moduleNames.push(matches[1]);
}
if (label.name.localeCompare("accepted") == 0) {
isAccepted = true;
}
});
moduleNames.forEach(function(moduleName) {
users.get(userId).set(moduleName, [entry.html_url, isAccepted]);
});
});
if (res.length == 100) {
pageId += 1;
fetchPullRequests();
} else {
renderTable();
}
});
}
fetchPullRequests();
</script>
</head>
<body>
<table id="results"></table>
</body>
</html>