@@ -3,17 +3,20 @@ const repoURL = `https://api.github.com/users/${USER}/repos`
33const projectsContainer = document . getElementById ( 'projects' )
44const 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+ }
0 commit comments