1+
2+
13const username = 'EmmaSprings'
24const projects = document . getElementById ( 'projects' )
5+ const API_URL_USER = `https://api.github.com/users/${ username } `
6+ const API_URL_REPO = `https://api.github.com/users/${ username } /repos`
7+
8+
39
410const fetchUser = ( ) => {
511
@@ -9,66 +15,155 @@ const fetchUser = () => {
915 Authorization : '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'
1016 }
1117 }
12- const API_URL_USER = `https://api.github.com/users/ ${ username } `
18+
1319 fetch ( API_URL_USER , options )
1420 . then ( ( res ) => res . json ( ) )
1521 . then ( ( data ) => {
1622 projects . innerHTML += `
17- <p>GitHub username = ${ data . login } </p>
18- <h2>Projects = [</h2>
19-
20- `
21- // header.innerHTML += `
22- // <img width="100" src="https://avatars.githubusercontent.com/u/94292545?v=4"/>
23- // `
23+ <div class="header-container">
24+ <img src="https://avatars.githubusercontent.com/u/94292545?v=4"/>
25+ <h1>GitHub tracker for Emma Springs</h1>
26+ <h2>user: <a href="https://api.github.com/users/EmmaSprings" class="login-name"> ${ data . login } </a> <br>
27+ ${ data . bio }
28+ </h2>
29+
30+ <p class="title">projects = [</p>
31+ </div>
32+ `
33+ console . log ( data ) //remove
34+
2435 fetchRepos ( ) ;
36+
37+
2538 } )
26-
2739
2840
29- const fetchRepos = ( ) => {
30- const API_URL_REPO = `https://api.github.com/users/ ${ username } /repos`
31- fetch ( API_URL_REPO , options )
32- . then ( ( res ) => res . json ( ) )
33- . then ( ( data ) => {
41+
42+ const fetchRepos = ( myProjects ) => {
43+ fetch ( API_URL_REPO , options )
44+ . then ( ( res ) => res . json ( ) )
45+ . then ( ( data ) => {
3446
35- const myProjects = data . filter ( ( repo ) => repo . name . includes ( "project-" ) && repo . fork ) ;
36-
47+ const myProjects = data . filter ( ( repo ) => repo . name . startsWith ( "project-" ) && repo . fork ) ;
48+
3749 myProjects . forEach ( ( repo => {
3850 projects . innerHTML += `
39- <li>
40- <a href="${ repo . html_url } " target="_blank">${ repo . name } </a>
41- <p>
42- This is ${ repo . name }
43- </p>
44- <li>
45- `
46- } ) )
47-
48- projects . innerHTML += `<h2 class="sign">]</h2>`
49-
50- } )
51-
52- } ;
53- myChart ( ) ;
54- } ;
55-
56-
57- fetchUser ( ) ;
51+ <li>
52+ <a href="${ repo . html_url } " target="_blank" class="repo-link">${ repo . name } </a>
53+ <p class="repo-info">
54+ <!-- This is ${ repo . name } -->
55+ </p>
56+ <p class="latest-push">
57+ latest push: ${ new Date ( repo . pushed_at ) . toDateString ( ) } </p>
58+ <p class="extra-info">main language: ${ repo . language } <br>
59+ branch: ${ repo . default_branch } <br>
60+ commits amount: ${ repo . commits_url . length } <br>
61+ <p id ="${ repo . name } ">Commits made by team member</p>
62+ pr: ${ length }
63+ </p>
64+
65+ <li>
66+ `
67+ } ) )
5868
69+ projects . innerHTML += `
70+ <p class="title">]</p>
71+ <h3>hello</h3>
72+ <!--<p>total repos = </p>-->
73+ `
5974
75+ drawChart ( myProjects . length ) ;
76+ fetchPullRequests ( myProjects ) ;
77+ console . log ( myProjects )
78+ } )
79+ } ;
80+
81+ const fetchPullRequests = ( myProjects ) => {
82+ // const API_URL_PRS = `https://api.github.com/repos/Technigo/${repo.name}/pulls?per_page=100`
83+
84+ myProjects . forEach ( repo => {
85+ fetch ( `https://api.github.com/repos/Technigo/${ repo . name } /pulls?per_page=100` )
86+ . then ( ( res ) => res . json ( ) )
87+ . then ( ( data ) => {
88+ const myPullRes = data . find ( pull => pull . user . login === repo . owner . login ) ;
6089
90+ const myCommitsURL = data . commits_url
91+ const repoName = repo . name
92+ fetchCommits ( myCommitsURL , repoName ) ;
93+ console . log ( myPullRes )
94+
6195
62- // const myProjects = data.filter((data) => data.name.includes("project-") && data.fork));
63- // const userRepos = data[0].name;
64- // for (i = 0; i < data.length; i++){
65- // projects.innerHTML += `
66- // <li>
67- // <a href="${data[i].html_url}" target="_blank">${data[i].name}</a>
68- // <p>
69- // This is ${data[i].name}
70- // </p>
71- // <li>
72- // `
73-
74- // };
96+
97+ } )
98+ } )
99+ }
100+
101+ } ;
102+
103+
104+
105+ fetchUser ( ) ;
106+
107+
108+
109+
110+
111+ const fetchCommits = ( myCommitsURL , repoName ) => {
112+
113+ fetch ( myCommitsURL , repoName )
114+ . then ( ( res ) => res . json ( ) )
115+ . then ( ( data ) => {
116+ document . getElementById ( repoName ) . innerHTML = `Number of commit: ${ data . length } `
117+ // document.getElementById(`commit-${dataName}`).innerHTML += data.length
118+ } )
119+ }
120+
121+
122+
123+
124+
125+
126+
127+
128+ // const myProjects = data.filter((data) => data.name.includes("project-") && data.fork));
129+ // const userRepos = data[0].name;
130+ // for (i = 0; i < data.length; i++){
131+ // projects.innerHTML += `
132+ // <li>
133+ // <a href="${data[i].html_url}" target="_blank">${data[i].name}</a>
134+ // <p>
135+ // This is ${data[i].name}
136+ // </p>
137+ // <li>
138+ // `
139+
140+ // };
141+
142+
143+
144+
145+
146+ // const fetchPulls = () => {
147+
148+ // const API_URL_PRS = `https://api.github.com/repos/Technigo/project-chatbot/pulls?per_page=100`
149+
150+ // fetch(API_URL_PRS)
151+ // .then((res) => res.json())
152+ // .then((data) => {
153+
154+ // const myPulls = data.filter((repo) => repo.login.includes(`${username}`)
155+
156+ // myPulls.forEach((repo {
157+
158+ // }))
159+
160+ // // projects.innerHTML += `
161+ // // <p>hello total repos = ${data[1].base.label} </p>
162+ // // `
163+ // console.log(data)
164+
165+ // fetchPullRequests(myProjects)
166+
167+ // });
168+
169+ // }
0 commit comments