1- let repoName = 'project-weather-app'
2-
3- const API_REPOS = `https://api.github.com/users/elsisco/repos`
4- const API_USER = `https://api.github.com/users/elsisco`
5- const API_PR = `https://api.github.com/repos/technigo/${ repoName } /pulls`
1+ const USER = 'elsisco'
2+ let repoName = 'project-weather-app' // Default value
63
4+ const API_REPOS = `https://api.github.com/users/${ USER } /repos`
5+ const API_USER = `https://api.github.com/users/${ USER } `
76
87const projectsContainer = document . getElementById ( 'projects' )
98const profileContainer = document . getElementById ( 'profile' )
109
10+ // Fetch content for profile section
1111const getUser = ( ) => {
1212 fetch ( API_USER )
1313 . then ( res => res . json ( ) )
@@ -31,26 +31,26 @@ const getUser = () => {
3131 } )
3232}
3333
34+ // Fetch content for projects section
3435const getRepos = ( ) => {
3536 fetch ( API_REPOS )
3637 . then ( res => res . json ( ) )
3738 . then ( data => {
3839 // Filtering the Technigo project repos
3940 const forkedRepos = data . filter ( repo => repo . fork && repo . name . startsWith ( 'project-' ) )
40-
41- // Sort array in alphabetical order
42- const sortedRepos = forkedRepos . sort ( )
4341
44- sortedRepos . forEach ( repo =>
45- fetch ( `https://api.github.com/repos/elsisco /${ repo . name } /commits` )
42+ forkedRepos . forEach ( repo =>
43+ fetch ( `https://api.github.com/repos/${ USER } /${ repo . name } /commits` )
4644 . then ( res => res . json ( ) )
4745 . then ( data => {
4846 // Formatting the title of projects to start all words with capital letter
4947 let projectName = `${ repo . name } `
48+
5049 const formattedProjectName = projectName . split ( "-" )
5150 for ( let i = 0 ; i < formattedProjectName . length ; i ++ ) {
5251 formattedProjectName [ i ] = formattedProjectName [ i ] [ 0 ] . toUpperCase ( ) + formattedProjectName [ i ] . substr ( 1 ) ;
5352 }
53+
5454 let newProjectName = formattedProjectName . join ( " " )
5555
5656 // Date for most recent update of project
@@ -66,9 +66,7 @@ const getRepos = () => {
6666 <p id="commits-${ repo . name } " class="text">(commits yet to be displayed)</p>
6767 <div class="languages">
6868 <p class="small-headline">Languages</p>
69-
70- <div id="progress-${ repo . name } " class="progress"></div>
71-
69+ <div id="progress-${ repo . name } " class="progress"></div>
7270 <section class="the-languages">
7371 <div class="html-wrapper">
7472 <div class="language-dot" style="background-color:#56B093;"></div>
@@ -94,9 +92,9 @@ const getRepos = () => {
9492 } )
9593}
9694
97- // A calculator for language percentage per project
95+ // A calculator for percentage of language per project
9896const calculateLanguagePercentage = ( repo ) => {
99- fetch ( `https://api.github.com/repos/elsisco /${ repo . name } /languages` )
97+ fetch ( `https://api.github.com/repos/${ USER } /${ repo . name } /languages` )
10098 . then ( res => res . json ( ) )
10199 . then ( language => {
102100 const html = language . HTML || 0 ;
@@ -116,23 +114,20 @@ const calculateLanguagePercentage = (repo) => {
116114 } )
117115}
118116
117+ // Fetch all pull requests per project
119118const fetchPullRequestsArray = ( allRepositories ) => {
120119 allRepositories . forEach ( repo => {
121120 fetch ( `https://api.github.com/repos/Technigo/${ repo . name } /pulls?per_page=100` )
122121 . then ( res => res . json ( ) )
123122 . then ( ( data ) => {
124- const myPullRequests = data . find ( ( pull ) => pull . user . login === repo . owner . login )
123+ // Hard coded the || below to get the commits for Project Chatbot for which I was not a collaborator
124+ const myPullRequests = data . find ( ( pull ) => pull . user . login === repo . owner . login || pull . user . login === 'Svempolin' && pull . number === 67 )
125125 fetchCommits ( myPullRequests . commits_url , repo . name )
126- // if (myPullRequests) {
127- // fetchCommits(myPullRequests.commits_url, repo.name)
128- // } else {
129- // document.getElementById(`commit-${repo.name}`).innerHTML +=
130- // 'No commits yet';
131- // }
132126 } )
133127 } )
134128}
135129
130+ // Fetching all the commits connected to the username
136131const fetchCommits = ( myCommitsUrl , myRepoName ) => {
137132 fetch ( myCommitsUrl )
138133 . then ( res => res . json ( ) )
@@ -142,5 +137,4 @@ const fetchCommits = (myCommitsUrl, myRepoName) => {
142137}
143138
144139getUser ( )
145-
146140getRepos ( )
0 commit comments