-
Notifications
You must be signed in to change notification settings - Fork 131
Week 7 Github Tracker Linnea Frisk #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2dc3bc3
d341be9
051e5d2
0dcd2c6
1a30493
ff81602
b672f03
4bebff4
ef4e9ef
dfb8323
6c8661a
9b783f3
8cc1f4c
19cc323
b4bfb3a
d61d311
5677eaa
b89cf18
3ff9333
d49c730
1999c36
e8f3da3
00b4257
33f06f0
f3af100
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
| # Ignore Mac system files | ||
| .DS_store | ||
| # Ignore node_modules folder | ||
| node_modules | ||
| # Ignore all text files | ||
| *.txt | ||
| # Ignore files related to API keys | ||
| .env | ||
| # misc | ||
| /.pnp | ||
| .pnp.js | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
|
|
||
| # other | ||
| code/token.js |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,11 @@ | ||
| # GitHub Tracker | ||
|
|
||
| Replace this readme with your own information about your project. | ||
| Week 7 @ Technigo Bootcamp | ||
|
|
||
| Start by briefly describing the assignment in a sentence or two. Keep it short and to the point. | ||
| This week I made a Github tracker, were you can scroll through my Technigo repositories. It also includes a chart of compleated and remaining projects in the Bootcamp. | ||
|
|
||
| ## The problem | ||
|
|
||
| Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next? | ||
| Made with JS, using API and authorization keys. | ||
|
|
||
| ## 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://project-github-tracker-linnea-frisk.netlify.app/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| // DOM SELECTORS | ||
| const USER = 'Neaa99' | ||
| const technigoRepos = document.getElementById('technigoRepos') | ||
| const container = document.getElementById('container') | ||
| const header = document.getElementById('header') | ||
|
|
||
| const API_TOKEN = TOKEN || process.env.API_KEY; | ||
|
|
||
| // API | ||
| const API_USER = `https://api.github.com/users/${USER}` | ||
| const API_REPOS = `https://api.github.com/users/${USER}/repos` | ||
|
|
||
| // Authorization | ||
| const options = { | ||
| method: 'GET', | ||
| headers: { | ||
| Authorization: `token ${API_TOKEN}` | ||
| } | ||
| } | ||
|
|
||
|
|
||
| fetch(API_USER, options) | ||
| .then ((res) => { | ||
| return res.json() | ||
| }) | ||
| .then ((data) => { | ||
| console.log(data) | ||
| header.innerHTML = ` | ||
| <a class="img-link" target="_blank" href="https://www.linkedin.com/in/linnea-frisk-59a170206/"><img src="${data.avatar_url}" width="100px" alt="User image"></a> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is interesting, I need to look into |
||
| <div class="header-text"> | ||
| <p>${data.name}</p> | ||
| <h1><span>${data.login}</span></h1> | ||
| <h1>GitHub Tracker</h1> | ||
| <p>${data.bio}</p> | ||
| </div>` | ||
| }) | ||
|
|
||
| fetch(API_REPOS, options) | ||
| .then ((res) => { | ||
| return res.json() | ||
| }) | ||
| .then((data) => { | ||
| console.log(data) | ||
| const technigoRepositories = data.filter(repo => | ||
| repo.name.includes('project-') && repo.fork === true) | ||
|
|
||
| technigoRepositories.forEach((repo) => { | ||
| container.innerHTML += ` | ||
| <div class="technigo-repos" id="technigoRepos"> | ||
| <a class="netlify-link" target="_blank" href="https://fascinated-jury-3fb.notion.site/Netlify-5e83f8322f8d4b92a96b4f0e8c2ccf96"><h2 id="repoName">${repo.name}</h2></a> | ||
| <h3 id="description">${repo.description}</h3> | ||
| <div class="info"> | ||
| <p><span>• Last push:</span> ${new Date(repo.pushed_at).toDateString()}</p> | ||
| <p><span>• Branch:</span> ${repo.default_branch}</p> | ||
| <p><span>• Main language:</span> ${repo.language}</p> | ||
| <p id="commit-${repo.name}"><span>• Number of commits:</span> </p> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really nice that you added info on the main language and the title of the page. |
||
| </div> | ||
| <p> <a class="repo-link" target="_blank" href="${repo.html_url}">Link to Repo</a></p> | ||
| </div> | ||
| ` | ||
| }) | ||
| drawChart(technigoRepositories.length) // Calling the chart | ||
| getPullRequests(technigoRepositories) // Calling the pull req and commits function | ||
| }) | ||
|
|
||
|
|
||
| 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`, options) | ||
| .then(res => res.json()) | ||
| .then(data => { | ||
| const commits = document.getElementById(`commit-${repo.name}`) | ||
|
|
||
| const pulls = data.find((pull) => pull.user.login === repo.owner.login); | ||
|
|
||
| fetchCommits(pulls.commits_url, repo.name) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was scratching my head how you got number of commits on all projects, but I think you were the person doing the pull each time? Unless there is some hidden trick I don't see :) |
||
| console.log(pulls.commits_url) | ||
|
|
||
| }) | ||
| }) | ||
| } | ||
|
|
||
| const fetchCommits = (myCommitsUrl, myRepoName) => { | ||
| fetch(myCommitsUrl, options) | ||
| .then((res) => { | ||
| return res.json() | ||
| }) | ||
| .then((data) => { | ||
| document.getElementById(`commit-${myRepoName}`).innerHTML += data.length | ||
|
|
||
| }) | ||
| } | ||
|
|
||
| // Center canvas/chart | ||
| window.onload = window.onresize = function() { | ||
| const canvas = document.getElementById('canvas'); | ||
| canvas.width = window.innerWidth * 0.8; | ||
| canvas.height = window.innerHeight * 0.8; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know many people struggled with the API token, so well done for setting it up! I skipped it this time, but planning to come back to it when I have time.