From c9185282b856bdf18b2534684025352f453d1a46 Mon Sep 17 00:00:00 2001 From: Fay Date: Wed, 23 Feb 2022 19:07:48 +0100 Subject: [PATCH 1/8] Fetched all repos(filters: forked, from Technigo) and fetched my PRs --- .gitignore | 1 + code/chart.js => chart.js | 2 +- code/index.html | 3 ++- code/script.js | 48 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 .gitignore rename code/chart.js => chart.js (50%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..c80900c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +code/secret.js \ No newline at end of file diff --git a/code/chart.js b/chart.js similarity index 50% rename from code/chart.js rename to chart.js index 92e85a30..6b16fd16 100644 --- a/code/chart.js +++ b/chart.js @@ -1,4 +1,4 @@ //DOM-selector for the canvas 👇 -const ctx = document.getElementById('chart').getContext('2d') +// const ctx = document.getElementById('chart').getContext('2d') //"Draw" the chart here 👇 diff --git a/code/index.html b/code/index.html index 2fb5e0ae..74599ecb 100644 --- a/code/index.html +++ b/code/index.html @@ -14,7 +14,8 @@

Projects:

- + + diff --git a/code/script.js b/code/script.js index e69de29b..547db8d1 100644 --- a/code/script.js +++ b/code/script.js @@ -0,0 +1,48 @@ + + +const options = { + method: 'GET', + headers: { + Authorization: `token ${API_TOKEN} ` // you need to paste your token over here. + } +} + +fetch('https://api.github.com/users/faypi/repos', options) // options object is passed as 2nd argument to fetch() function. + .then(res => res.json()) + .then(data => { + // console.log(data); + const newData = data.filter((forkedRepos) => forkedRepos.fork == true && forkedRepos.name.startsWith("project-")) + console.log(newData) + //am I passing along my filter repos? + getPullRequests(newData) + }); + +//Remember to pass along your filtered repos as an argument when +//you are calling this function + +const getPullRequests = (repos) => { + //Get all the PRs for each project. + // console.log('my repos follow') + // console.log(repos) + repos.forEach(repo => { + fetch('https://api.github.com/repos/technigo/' + repo.name + '/pulls' + '?per_page=100') + .then(res => res.json()) + .then(data => { + //TODO + //1. Find only the PR that you made by comparing pull.user.login + // with repo.owner.login + // console.log(data); + const myPullRequests = data.filter((myPR) => myPR.user.login == repo.owner.login); + console.log(myPullRequests); + //2. Now you're able to get the commits for each repo by using + // the commits_url as an argument to call another function + + + //3. You can also get the comments for each PR by calling + // another function with the review_comments_url as argument + }) + }) +} + +// script.js file +console.log(API_TOKEN); // 'HERE_WILL_BE_YOUR_TOKEN' \ No newline at end of file From a4cb298d7600d9a878b2f86050a2ca8640cf32d5 Mon Sep 17 00:00:00 2001 From: Fay Date: Sat, 26 Feb 2022 17:24:25 +0100 Subject: [PATCH 2/8] got all data for blue lvl --- code/script.js | 124 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 110 insertions(+), 14 deletions(-) diff --git a/code/script.js b/code/script.js index 547db8d1..70731373 100644 --- a/code/script.js +++ b/code/script.js @@ -1,5 +1,7 @@ - - +const username = 'faypi' +const API_URL = `https://api.github.com/users/${username}/repos` +const API_USER_PROFILE = `https://api.github.com/users/${username}` +// const API_TOKEN = TOKEN || process.env.API_KEY; const options = { method: 'GET', headers: { @@ -7,14 +9,26 @@ const options = { } } -fetch('https://api.github.com/users/faypi/repos', options) // options object is passed as 2nd argument to fetch() function. +fetch(API_USER_PROFILE, options) + .then(res => res.json()) + .then(data => { + console.log(data) + const name = data.name + const profilePic = data.avatar_url + // const memberSince = data.created_at + const followers = data.followers + const following = data.following + + } + ) + + +fetch(API_URL, options) // options object is passed as 2nd argument to fetch() function. .then(res => res.json()) .then(data => { // console.log(data); - const newData = data.filter((forkedRepos) => forkedRepos.fork == true && forkedRepos.name.startsWith("project-")) - console.log(newData) - //am I passing along my filter repos? - getPullRequests(newData) + const myRepos = data.filter((forkedRepos) => forkedRepos.fork == true && forkedRepos.name.startsWith("project-")) + getPullRequests(myRepos) }); //Remember to pass along your filtered repos as an argument when @@ -22,27 +36,109 @@ fetch('https://api.github.com/users/faypi/repos', options) // options object is const getPullRequests = (repos) => { //Get all the PRs for each project. - // console.log('my repos follow') - // console.log(repos) repos.forEach(repo => { fetch('https://api.github.com/repos/technigo/' + repo.name + '/pulls' + '?per_page=100') .then(res => res.json()) .then(data => { + + // console.log(`repo default branch ${repo.default_branch}`) + const repoBranchName = repo.default_branch + const repoName = repo.full_name + const repoUrl = repo.url + // console.log() //TODO //1. Find only the PR that you made by comparing pull.user.login // with repo.owner.login // console.log(data); const myPullRequests = data.filter((myPR) => myPR.user.login == repo.owner.login); - console.log(myPullRequests); - //2. Now you're able to get the commits for each repo by using - // the commits_url as an argument to call another function + // console.log('this is my pRs') + console.log(`pull requests for ${repoName}`); + // console.log(myPullRequests); + myPullRequests.forEach(pullRequest => { + const prTitle = pullRequest.title + const prUrl = pullRequest.url + console.log(prTitle) + console.log(prUrl) + }) + // return myPullRequests + const myCommits = myPullRequests.map((mycomm) => mycomm.commits_url) + // getCommits(COMMITS) + // console.log("my commits") + // console.log(myCommits) + // getCommits(myCommits) + //2. Now you're able to get the commits for each repo by using + // the commits_url as an argument to call another function //3. You can also get the comments for each PR by calling // another function with the review_comments_url as argument + const comments = myPullRequests.map((comment) => comment.review_comments_url) + // console.log(comments) + }) + }) + +} + + + +const getCommits = (commitUrls) => { + //Get all the PRs for each project. + commitUrls.forEach(commitUrl => { + fetch(commitUrl + "?per_page=100") + .then(res => res.json()) + .then(data => { + console.log('commit new') + console.log(data.length) + const mostRecentCommit = data[data.length - 1] + console.log(mostRecentCommit) + const commitMessage = mostRecentCommit.commit.message + console.log(mostRecentCommit.commit.message) + const commitAuthor = mostRecentCommit.author.login + const commitUrl = mostRecentCommit.html_url + const commitDateString = mostRecentCommit.commit.author.date + console.log(commitDateString) + const commitDate = Date.parse(commitDateString) + console.log(commitDate) + const commitTimeSince = timeSince(commitDate) + console.log(commitTimeSince) + + + + }) }) } -// script.js file -console.log(API_TOKEN); // 'HERE_WILL_BE_YOUR_TOKEN' \ No newline at end of file +// getCommits(myPullRequests) +// const getCommits = myPullRequests.map((mycomm) =>mycomm.commits_url) +// console.log('this is my commits') +// console.log(getCommits); +// return getCommits + +function timeSince(date) { + + var seconds = Math.floor((new Date() - date) / 1000); + + var interval = seconds / 31536000; + + if (interval > 1) { + return Math.floor(interval) + " years ago"; + } + interval = seconds / 2592000; + if (interval > 1) { + return Math.floor(interval) + " months ago"; + } + interval = seconds / 86400; + if (interval > 1) { + return Math.floor(interval) + " days ago"; + } + interval = seconds / 3600; + if (interval > 1) { + return Math.floor(interval) + " hours ago"; + } + interval = seconds / 60; + if (interval > 1) { + return Math.floor(interval) + " minutes ago"; + } + return Math.floor(seconds) + " seconds ago"; +} \ No newline at end of file From 347c381ae9b04c96005775c59720f176d5a67bbe Mon Sep 17 00:00:00 2001 From: Fay Date: Sun, 27 Feb 2022 17:46:12 +0100 Subject: [PATCH 3/8] present data to html --- code/index.html | 4 +- code/script.js | 128 +++++++++++++++++++++++++++--------------------- 2 files changed, 75 insertions(+), 57 deletions(-) diff --git a/code/index.html b/code/index.html index 74599ecb..c3064ad3 100644 --- a/code/index.html +++ b/code/index.html @@ -8,13 +8,13 @@ -

GitHub Tracker

+

Projects:

- + diff --git a/code/script.js b/code/script.js index 70731373..d388b888 100644 --- a/code/script.js +++ b/code/script.js @@ -1,6 +1,9 @@ const username = 'faypi' const API_URL = `https://api.github.com/users/${username}/repos` const API_USER_PROFILE = `https://api.github.com/users/${username}` +const projects = document.getElementById("projects"); +const profile = document.getElementById("profile"); +const totalProjectsDuringBootcamp = 19; // const API_TOKEN = TOKEN || process.env.API_KEY; const options = { method: 'GET', @@ -12,13 +15,21 @@ const options = { fetch(API_USER_PROFILE, options) .then(res => res.json()) .then(data => { - console.log(data) const name = data.name const profilePic = data.avatar_url // const memberSince = data.created_at const followers = data.followers const following = data.following - + profile.innerHTML += ` +

${username}'s GitHub Tracker

+
+ + ${name} + ${username} + following ${following} + followed by ${followers} +
+ ` } ) @@ -26,8 +37,11 @@ fetch(API_USER_PROFILE, options) fetch(API_URL, options) // options object is passed as 2nd argument to fetch() function. .then(res => res.json()) .then(data => { - // console.log(data); const myRepos = data.filter((forkedRepos) => forkedRepos.fork == true && forkedRepos.name.startsWith("project-")) + const numberOfProjects = myRepos.length + console.log(totalProjectsDuringBootcamp) + console.log(numberOfProjects) + console.log(totalProjectsDuringBootcamp - numberOfProjects) getPullRequests(myRepos) }); @@ -37,43 +51,28 @@ fetch(API_URL, options) // options object is passed as 2nd argument to fetch() f const getPullRequests = (repos) => { //Get all the PRs for each project. repos.forEach(repo => { - fetch('https://api.github.com/repos/technigo/' + repo.name + '/pulls' + '?per_page=100') + fetch('https://api.github.com/repos/technigo/' + repo.name + '/pulls' + '?per_page=100', options) .then(res => res.json()) .then(data => { - - // console.log(`repo default branch ${repo.default_branch}`) const repoBranchName = repo.default_branch - const repoName = repo.full_name - const repoUrl = repo.url - // console.log() - //TODO - //1. Find only the PR that you made by comparing pull.user.login - // with repo.owner.login - // console.log(data); + const repoName = repo.name + const repoUrl = repo.html_url + + + projects.innerHTML += ` + + ` + console.log("here") + const myPullRequests = data.filter((myPR) => myPR.user.login == repo.owner.login); - // console.log('this is my pRs') - console.log(`pull requests for ${repoName}`); - // console.log(myPullRequests); - myPullRequests.forEach(pullRequest => { - - const prTitle = pullRequest.title - const prUrl = pullRequest.url - - console.log(prTitle) - console.log(prUrl) - }) - // return myPullRequests - const myCommits = myPullRequests.map((mycomm) => mycomm.commits_url) - // getCommits(COMMITS) - // console.log("my commits") - // console.log(myCommits) - // getCommits(myCommits) - //2. Now you're able to get the commits for each repo by using - // the commits_url as an argument to call another function - //3. You can also get the comments for each PR by calling - // another function with the review_comments_url as argument - const comments = myPullRequests.map((comment) => comment.review_comments_url) - // console.log(comments) + console.log(data) + handlePullRequest(repoName, myPullRequests) }) }) @@ -81,39 +80,58 @@ const getPullRequests = (repos) => { -const getCommits = (commitUrls) => { +const handlePullRequest = (repoElementId, myPullRequests) => { + const repo = document.getElementById(repoElementId); + //Get all the PRs for each project. - commitUrls.forEach(commitUrl => { - fetch(commitUrl + "?per_page=100") + myPullRequests + .forEach((pullRequest) => { + const prTitle = pullRequest.title + const prUrl = pullRequest.html_url + repo.innerHTML += ` +
+ PR: ${prTitle} +
+ ` + // return pullRequest.commits_url + }) + myPullRequests + .map(pullRequest => pullRequest.commits_url) + .forEach(commitUrl => { + fetch(commitUrl + "?per_page=100", options) .then(res => res.json()) .then(data => { - console.log('commit new') - console.log(data.length) const mostRecentCommit = data[data.length - 1] - console.log(mostRecentCommit) const commitMessage = mostRecentCommit.commit.message - console.log(mostRecentCommit.commit.message) const commitAuthor = mostRecentCommit.author.login const commitUrl = mostRecentCommit.html_url const commitDateString = mostRecentCommit.commit.author.date - console.log(commitDateString) const commitDate = Date.parse(commitDateString) - console.log(commitDate) const commitTimeSince = timeSince(commitDate) - console.log(commitTimeSince) - - - - + repo.innerHTML += ` +
+

${data.length} commits

+

latest: ${commitMessage} by ${commitAuthor} ${commitTimeSince}

+
+ ` }) }) + + myPullRequests + .map(pullRequest => pullRequest.review_comments_url) + .forEach(reviewCommentUrl => { + fetch(reviewCommentUrl + "?per_page=100", options) + .then(res => res.json()) + .then(data => { + repo.innerHTML += ` +
+ received ${data.length} comments +
+ ` + }) + }) } -// getCommits(myPullRequests) -// const getCommits = myPullRequests.map((mycomm) =>mycomm.commits_url) -// console.log('this is my commits') -// console.log(getCommits); -// return getCommits function timeSince(date) { From c1ccc8e1d6c7b0392c9a3dbfe904faec2ced2097 Mon Sep 17 00:00:00 2001 From: Fay Date: Sun, 27 Feb 2022 18:58:22 +0100 Subject: [PATCH 4/8] added chart and styling --- chart.js | 4 ---- code/chart.js | 29 +++++++++++++++++++++++++ code/index.html | 14 +++++++++--- code/script.js | 20 ++++++++--------- code/style.css | 58 ++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 107 insertions(+), 18 deletions(-) delete mode 100644 chart.js create mode 100644 code/chart.js diff --git a/chart.js b/chart.js deleted file mode 100644 index 6b16fd16..00000000 --- a/chart.js +++ /dev/null @@ -1,4 +0,0 @@ -//DOM-selector for the canvas 👇 -// const ctx = document.getElementById('chart').getContext('2d') - -//"Draw" the chart here 👇 diff --git a/code/chart.js b/code/chart.js new file mode 100644 index 00000000..607ecd57 --- /dev/null +++ b/code/chart.js @@ -0,0 +1,29 @@ +//DOM-selector for the canvas 👇 +const ctx = document.getElementById('chart').getContext('2d') + +//"Draw" the chart here 👇 + +const drawChart = (dataPoints) => { + + const data = { + labels: ["Finished Projects", "Unfinished Projects"], + datasets: [{ + label: '# of Projects', + data: dataPoints, + backgroundColor: [ + 'rgb(54, 162, 235)', + 'rgb(255, 205, 86)' + ], + borderWidth: 1, + hoverOffset: 4 + }] + }; + + + const config = { + type: 'doughnut', + data: data, + }; + + const myChart = new Chart(ctx, config) +} diff --git a/code/index.html b/code/index.html index c3064ad3..dbc97c18 100644 --- a/code/index.html +++ b/code/index.html @@ -6,17 +6,25 @@ Project GitHub Tracker + + + -
+
+
+ +
+

Projects:

+
- - + \ No newline at end of file diff --git a/code/script.js b/code/script.js index d388b888..ab4c9180 100644 --- a/code/script.js +++ b/code/script.js @@ -23,7 +23,7 @@ fetch(API_USER_PROFILE, options) profile.innerHTML += `

${username}'s GitHub Tracker

- + ${name} ${username} following ${following} @@ -39,9 +39,7 @@ fetch(API_URL, options) // options object is passed as 2nd argument to fetch() f .then(data => { const myRepos = data.filter((forkedRepos) => forkedRepos.fork == true && forkedRepos.name.startsWith("project-")) const numberOfProjects = myRepos.length - console.log(totalProjectsDuringBootcamp) - console.log(numberOfProjects) - console.log(totalProjectsDuringBootcamp - numberOfProjects) + drawChart([numberOfProjects, totalProjectsDuringBootcamp-numberOfProjects]) getPullRequests(myRepos) }); @@ -60,12 +58,14 @@ const getPullRequests = (repos) => { projects.innerHTML += ` -
-

- - ${repoName}:${repoBranchName} - -

+ ` console.log("here") diff --git a/code/style.css b/code/style.css index 7c8ad447..c51c7746 100644 --- a/code/style.css +++ b/code/style.css @@ -1,3 +1,59 @@ body { - background: #FFECE9; + margin: 0 auto; + font-family: 'Titillium Web', sans-serif; +} + +#projects { + display: flex; + flex-wrap: wrap; + justify-content: center; +} + +.repo-card { + max-width: 250px; + margin-bottom: 30px; + border: 1px solid #776c6c42; +} + +.repo { + padding: 20px; + display: flex; + flex-direction: column; + justify-content: space-between; +} + +.repo a { + color: inherit; +} + +#chart { + margin: 20px 0; +} + +.profile-card { + display: flex; + flex-direction: column; + max-width: 250px; + margin: 0 auto; +} + +.profile-details { + display: flex; + flex-direction: column; + text-align: center; +} + +.profile-details img { + width: 100%; + border-radius: 30%; +} + +h1, h2 { +text-align: center; +} + +@media (min-width: 530px) { + #projects { + justify-content: space-between; + } } \ No newline at end of file From d290c3f9a6da5227ffdcd15b39a4569f24edd500 Mon Sep 17 00:00:00 2001 From: Fay Date: Sun, 27 Feb 2022 19:11:17 +0100 Subject: [PATCH 5/8] formatting --- code/script.js | 73 +++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/code/script.js b/code/script.js index ab4c9180..a14f4508 100644 --- a/code/script.js +++ b/code/script.js @@ -20,7 +20,7 @@ fetch(API_USER_PROFILE, options) // const memberSince = data.created_at const followers = data.followers const following = data.following - profile.innerHTML += ` + profile.innerHTML += `

${username}'s GitHub Tracker

@@ -39,7 +39,7 @@ fetch(API_URL, options) // options object is passed as 2nd argument to fetch() f .then(data => { const myRepos = data.filter((forkedRepos) => forkedRepos.fork == true && forkedRepos.name.startsWith("project-")) const numberOfProjects = myRepos.length - drawChart([numberOfProjects, totalProjectsDuringBootcamp-numberOfProjects]) + drawChart([numberOfProjects, totalProjectsDuringBootcamp - numberOfProjects]) getPullRequests(myRepos) }); @@ -52,11 +52,11 @@ const getPullRequests = (repos) => { fetch('https://api.github.com/repos/technigo/' + repo.name + '/pulls' + '?per_page=100', options) .then(res => res.json()) .then(data => { + const repoBranchName = repo.default_branch const repoName = repo.name const repoUrl = repo.html_url - projects.innerHTML += `
@@ -68,71 +68,66 @@ const getPullRequests = (repos) => {
` - console.log("here") + const myPullRequests = data.filter((myPR) => myPR.user.login == repo.owner.login); - console.log(data) handlePullRequest(repoName, myPullRequests) }) }) } - - const handlePullRequest = (repoElementId, myPullRequests) => { const repo = document.getElementById(repoElementId); //Get all the PRs for each project. myPullRequests - .forEach((pullRequest) => { - const prTitle = pullRequest.title - const prUrl = pullRequest.html_url - repo.innerHTML += ` + .forEach((pullRequest) => { + const prTitle = pullRequest.title + const prUrl = pullRequest.html_url + repo.innerHTML += ` ` - // return pullRequest.commits_url }) myPullRequests - .map(pullRequest => pullRequest.commits_url) - .forEach(commitUrl => { - fetch(commitUrl + "?per_page=100", options) - .then(res => res.json()) - .then(data => { - const mostRecentCommit = data[data.length - 1] - const commitMessage = mostRecentCommit.commit.message - const commitAuthor = mostRecentCommit.author.login - const commitUrl = mostRecentCommit.html_url - const commitDateString = mostRecentCommit.commit.author.date - const commitDate = Date.parse(commitDateString) - const commitTimeSince = timeSince(commitDate) - repo.innerHTML += ` + .map(pullRequest => pullRequest.commits_url) + .forEach(commitUrl => { + fetch(commitUrl + "?per_page=100", options) + .then(res => res.json()) + .then(data => { + const mostRecentCommit = data[data.length - 1] + const commitMessage = mostRecentCommit.commit.message + const commitAuthor = mostRecentCommit.author.login + const commitUrl = mostRecentCommit.html_url + const commitDateString = mostRecentCommit.commit.author.date + const commitDate = Date.parse(commitDateString) + const commitTimeSince = timeSince(commitDate) + repo.innerHTML += `

${data.length} commits

latest: ${commitMessage} by ${commitAuthor} ${commitTimeSince}

` - }) - }) + }) + }) myPullRequests - .map(pullRequest => pullRequest.review_comments_url) - .forEach(reviewCommentUrl => { - fetch(reviewCommentUrl + "?per_page=100", options) - .then(res => res.json()) - .then(data => { - repo.innerHTML += ` -
- received ${data.length} comments -
- ` + .map(pullRequest => pullRequest.review_comments_url) + .forEach(reviewCommentUrl => { + fetch(reviewCommentUrl + "?per_page=100", options) + .then(res => res.json()) + .then(data => { + repo.innerHTML += ` +
+ received ${data.length} comments +
+ ` + }) }) - }) } - function timeSince(date) { var seconds = Math.floor((new Date() - date) / 1000); From 80d71946083e5d6f82e824ed56d7cbbaeb94da56 Mon Sep 17 00:00:00 2001 From: Fay Date: Sun, 27 Feb 2022 19:16:39 +0100 Subject: [PATCH 6/8] added netflify link on readme file --- README.md | 2 +- code/script.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1613a3b0..61736952 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,4 @@ Describe how you approached to problem, and what tools and techniques you used t ## View it live -Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about. +https://fay-github-tracker.netlify.app/ diff --git a/code/script.js b/code/script.js index a14f4508..3f6a5057 100644 --- a/code/script.js +++ b/code/script.js @@ -8,7 +8,7 @@ const totalProjectsDuringBootcamp = 19; const options = { method: 'GET', headers: { - Authorization: `token ${API_TOKEN} ` // you need to paste your token over here. + Authorization: `token ${API_TOKEN}` // you need to paste your token over here. } } From 49e384c4f37848635128a97f67d01a1777952ae5 Mon Sep 17 00:00:00 2001 From: Fay Date: Sun, 27 Feb 2022 19:49:10 +0100 Subject: [PATCH 7/8] get element before changing it --- code/script.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/script.js b/code/script.js index 3f6a5057..a84a3a63 100644 --- a/code/script.js +++ b/code/script.js @@ -78,13 +78,13 @@ const getPullRequests = (repos) => { } const handlePullRequest = (repoElementId, myPullRequests) => { - const repo = document.getElementById(repoElementId); //Get all the PRs for each project. myPullRequests .forEach((pullRequest) => { const prTitle = pullRequest.title const prUrl = pullRequest.html_url + const repo = document.getElementById(repoElementId); repo.innerHTML += `
PR: ${prTitle} @@ -104,6 +104,7 @@ const handlePullRequest = (repoElementId, myPullRequests) => { const commitDateString = mostRecentCommit.commit.author.date const commitDate = Date.parse(commitDateString) const commitTimeSince = timeSince(commitDate) + const repo = document.getElementById(repoElementId); repo.innerHTML += `

${data.length} commits

@@ -119,6 +120,7 @@ const handlePullRequest = (repoElementId, myPullRequests) => { fetch(reviewCommentUrl + "?per_page=100", options) .then(res => res.json()) .then(data => { + const repo = document.getElementById(repoElementId); repo.innerHTML += `
received ${data.length} comments From f44d0779d79b6ad46fd65c6570f2f0e50e82bc53 Mon Sep 17 00:00:00 2001 From: Fay Date: Sun, 6 Mar 2022 20:56:24 +0100 Subject: [PATCH 8/8] fetch comments after PRs --- code/script.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/code/script.js b/code/script.js index a84a3a63..06f80243 100644 --- a/code/script.js +++ b/code/script.js @@ -110,24 +110,26 @@ const handlePullRequest = (repoElementId, myPullRequests) => {

${data.length} commits

latest: ${commitMessage} by ${commitAuthor} ${commitTimeSince}

- ` - }) - }) - - myPullRequests - .map(pullRequest => pullRequest.review_comments_url) - .forEach(reviewCommentUrl => { - fetch(reviewCommentUrl + "?per_page=100", options) - .then(res => res.json()) - .then(data => { - const repo = document.getElementById(repoElementId); - repo.innerHTML += ` -
- received ${data.length} comments -
` + + + myPullRequests + .map(pullRequest => pullRequest.review_comments_url) + .forEach(reviewCommentUrl => { + fetch(reviewCommentUrl + "?per_page=100", options) + .then(res => res.json()) + .then(data => { + const repo = document.getElementById(repoElementId); + repo.innerHTML += ` +
+ received ${data.length} comments +
+ ` + }) + }) }) }) + } function timeSince(date) {