Skip to content

Commit 64bb58e

Browse files
Kara HowesKara Howes
authored andcommitted
showed PRs from Technigo and filtered to show only my PRs
1 parent 822fac3 commit 64bb58e

3 files changed

Lines changed: 48 additions & 16 deletions

File tree

code/chart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const drawChart = (amount) =>{
1313
],
1414
datasets: [{
1515
label: 'My First Dataset',
16-
data: [amount , 24-amount],
16+
data: [amount , 20-amount],
1717
backgroundColor: [
1818
'rgb(255, 99, 132)',
1919
'rgb(54, 162, 235)'

code/script.js

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ const repoURL = `https://api.github.com/users/${USER}/repos`
33
const projectsContainer = document.getElementById('projects')
44
const cardsContainer = document.getElementById('cards-container')
55

6-
const getRepos = ()=>{
76

7+
8+
const getRepos = ()=>{
9+
// This function fetches the data from the Githug API
810
fetch(repoURL)
911
.then(response => response.json())
1012
.then(data => {
11-
console.log(data)
12-
//projectsContainer.innerHTML = `The name of your first project was ${data[0].name}`
1313

14-
const forkedProjects = data.filter(repo => repo.fork && repo.name.startsWith('project-'))
14+
//console.log(data)
15+
//Here, I filter only the projects forked from Technigo, starting from 2021 (since I have earlier projects also forked from Technigo)
16+
const forkedProjects = data.filter(repo => repo.fork && repo.name.startsWith('project-') && repo.created_at.startsWith('2021-'))
17+
// Here I update the projectsContainer.innerHTML to show a list of all forked repos
1518
forkedProjects.forEach(repo => projectsContainer.innerHTML += `<h3>${repo.name}</h3>`)
16-
19+
// Here I update the cards.Container to show cards with data extracted from the GitHUb API
1720
forkedProjects.forEach(repo => cardsContainer.innerHTML += `
1821
<section class="js-card">
1922
<div class="card-projectname" id="cardProjectName">
@@ -25,26 +28,55 @@ const getRepos = ()=>{
2528
Name of default branch: ${repo.default_branch}
2629
</div>
2730
<div class= "URL" id="cardURL">
28-
URL: ${repo.url}
31+
URL: <a href="${repo.svn_url} ">Clicky</a>
2932
</div>
3033
<div class= "number-commits" id="cardCommits">
3134
Number of commit Messages:
3235
</div>
33-
<div class= "blank-line" id="cardBlank">
34-
blank
36+
<div class= "times-forked" id="cardForked">
37+
Number of times forked: ${repo.forks}
3538
</div>
3639
<div class= "blank-line" id="cardBlank">
3740
blank
3841
</div>
3942
4043
4144
</section>`)
42-
45+
// Here we store the forkedProjects.length and console.log to make sure it is correct.
4346
drawChart(forkedProjects.length)
44-
console.log('hello', forkedProjects.length)
45-
46-
}
47-
)
47+
//console.log('hello', forkedProjects.length)
48+
getPullRequests(forkedProjects)
49+
})
50+
}
51+
52+
getRepos()
53+
54+
const getPullRequests = (forkedProjects) => {
55+
56+
forkedProjects.forEach((repo) => {
57+
58+
fetch(`https://api.github.com/repos/technigo/${repo.name}/pulls?per_page=100`)
59+
.then((response) => response.json())
60+
.then((data) => {
61+
//console.log(data)
62+
const myPullRequests = data.filter(pull => pull.user.login === repo.owner.login)
63+
//console.log(myPullRequests)
64+
65+
})
66+
getCommits(commits_url)
67+
})
4868
}
4969

50-
getRepos()
70+
const getCommits = (commits_url) =>{
71+
72+
commits_url.forEach((repo)=> {
73+
74+
fetch(`https://api.github.com/repos/technigo/${repo.name}/pulls/${repo.number}/commits`)
75+
.then((response)=> response.json())
76+
.then((data)=>{
77+
console.log(data)
78+
})
79+
80+
})
81+
82+
}

code/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ body {
3434
padding: 20px 0 0 0;
3535
border-bottom: 3px solid pink
3636
}
37-
.updated, .branch, .URL, .number-commits, .blank-line {
37+
.updated, .branch, .URL, .number-commits, .blank-line, .times-forked {
3838
margin: 6px 0 0 0;
3939
padding: 6px 0 0 0;
4040
border-bottom: 1px solid #B2B3B4;

0 commit comments

Comments
 (0)