-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
24 lines (19 loc) · 701 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function calculate() {
const users = JSON.parse(localStorage.getItem('users'));
if (users && Array.isArray(users)) {
Promise.all(users.map(getPullRequestHacktoberfest))
.then(results => results.reduce((total, count) => total += count, 0))
.then(total => {
if(total < 10) {
total = "0" + total;
}
document.getElementById('pr').innerHTML = `<span class="count">${total}</span>`
});
}
}
function getPullRequestHacktoberfest(author) {
return fetch(`https://api.github.com/search/issues?q=type:pr+author:${author}+created:%3E2018-10-01`)
.then(response => response.json())
.then(json => json['total_count']);
}
calculate();