-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathindex.html
118 lines (104 loc) · 3.74 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
112
113
114
115
116
117
118
<!DOCTYPE html>
<html>
<head>
<style>
table {
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
text-align: center;
padding: 5px;
}
</style>
<script type="module">
import { Octokit } from "https://esm.sh/@octokit/rest";
const octokit = new Octokit();
let realNames = {};
try {
let res = await fetch("https://devtools-course-practice-hluq.onrender.com/names");
realNames = await res.json();
} catch {};
octokit.paginate(octokit.rest.pulls.list, {
owner: "UNN-ITMM-Software",
repo: "devtools-course-practice",
state: "all",
sort: "created",
direction: "asc",
})
.then(pulls => {
let results = {};
pulls.forEach(pull => {
let task_id
let isPlagiarized = false;
let isDelayed = false;
pull.labels.forEach(label => {
if(label.name == "lab 1" || label.name == "lab 2" || label.name == "lab 3") {
task_id = label.name;
} else if (label.name == "plagiarized") {
isPlagiarized = true;
} else if (label.name == "delayed") {
isDelayed = true;
}
});
if (!task_id)
return;
task_id = parseInt(task_id.at(-1));
if (task_id < 1 || task_id > 3)
return;
let username = pull.user.login;
if (!(username in results)) {
results[username] = {1: {}, 2: {}, 3: {}};
}
if (pull.state === 'closed' && pull.merged_at != null) {
results[username][task_id].status ='success';
results[username][task_id].html_url = pull.html_url;
} else if (pull.state === 'open') {
results[username][task_id].status = 'progress';
results[username][task_id].html_url = pull.html_url;
}
if (isPlagiarized) {
results[username][task_id].status ='plagiarized';
results[username][task_id].html_url = pull.html_url;
}
if (isDelayed) {
results[username][task_id].status ='delayed';
results[username][task_id].html_url = pull.html_url;
}
});
document.getElementById("loading").innerHTML = "";
var table = document.getElementById("results");
var header = table.insertRow();
header.insertCell().innerHTML = "User name";
header.insertCell().innerHTML = "Lab 1";
header.insertCell().innerHTML = "Lab 2";
header.insertCell().innerHTML = "Lab 3";
for (const [userId, progress] of Object.entries(results)) {
var row = table.insertRow();
let name = userId in realNames ? realNames[userId] : userId;
row.insertCell().innerHTML = "<a href=https://github.com/" + userId + ">" + name + "</a>";
for (let i = 1; i <= 3; ++i) {
var cell = row.insertCell();
if (!progress[i].status)
continue;
var html = "<a href=" + progress[i].html_url + "><img src='https://img.shields.io/badge/";
if (progress[i].status === "success") {
html += "-accepted-4BC51D";
} else if (progress[i].status === "plagiarized") {
html += "!-plagiarized-blueviolet";
} else if (progress[i].status === "delayed") {
html += "!-delayed-orange";
} else {
html += "-in progress-red";
}
cell.innerHTML = html + "?style=plastic'></a>";
}
}
});
</script>
</head>
<body>
<div id="loading">Loading...</div>
<table id="results"></table>
</body>
</html>