-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayground.js
More file actions
76 lines (66 loc) · 2.91 KB
/
Copy pathplayground.js
File metadata and controls
76 lines (66 loc) · 2.91 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
(function () {
const username = 'gassio'
const githubToken = 'ea41eb5c55dfca4145456b9619c00f0be6da4982'
var theData = {
testArray: [{ id: 1, title: 'asdf'}],
repo: ['tensorflow/tensorflow', 'twbs/bootstrap', 'microsoft/vscode'],
perPage: 100,
page: 0,
issues: [],
events: [],
eventIssues: [],
}
var exportToExcel = function(events, columns) {
console.log(events)
var wb = XLSX.utils.book_new()
var ws = XLSX.utils.json_to_sheet(events, { header: columns })
XLSX.utils.book_append_sheet(wb, ws, 'events-issues')
XLSX.writeFile(wb, 'events-and-issues.xlsx')
}
var fetchIssues = function () {
fetch('https://api.github.com/search/issues?q=' + theData.repo + '+type:issue').then(function (response) {
if (response.ok) return response.json();
return Promise.reject(response);
})
.then(function (issues) {
for (let i=0; i < issues.length; i++) {
fetch('https://api.github.com/repos/' + theData.repo + '/issues/' + issues.number + '/events').then(function (response) {
if (response.ok) return response.json()
return Promise.reject(response)
})
.then(function(events) {
for (let j=0; j < events.length; j++) {
console.log(theData.issues[issueId].id + ' ' + events[j].event + ' ' + events[j].created_at + ' ' + events[j].actor.login + ' ' + theData.issues[issueId].title)
}
})
.catch(function(err) {
console.log(err)
})
}
})
.catch(function (error) {
console.warn('Something went wrong.', error);
});
}
var fetchEvents = function (issueId) {
fetch('https://api.github.com/repos/' + theData.repo + '/issues/' + issueId + '/events').then(function (response) {
if (response.ok) return response.json()
return Promise.reject(response)
})
.then(function(data) {
for (let j=0; j < data.length; j++) {
console.log(theData.issues[issueId].id + ' ' + data[j].event + ' ' + data[j].created_at + ' ' + data[k].actor.login + ' ' + theData.issues[issueId].title + ' ' )
}
// theData.events = data
// for (let j=0; j < theData.events.length; j++) {
// console.log(theData.issues[issueId].id + ' ' + theData.issues[issueId].title + ' ' + theData.events[j].event + " at " + theData.events[j].created_at)
// let line = { "id": theData.issues[issueId].id, "title": theData.issues[issueId].title, "event_name": theData.events[j].event, "event_time": theData.events[j].created_at }
// theData.eventIssues.push(line)
// }
// return theData.eventIssues
})
.catch(function (error) {
console.log(error)
})
}
})()