Compare commits
10 Commits
5604408244
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
b48b218ee8
|
|||
|
75c00d911f
|
|||
|
|
feb6342a68 | ||
|
|
fb34587b1c | ||
|
|
e9fd8681ac | ||
|
|
2a0bfb6add | ||
|
a6d18f90bb
|
|||
|
6e1d5a472e
|
|||
|
15acf5935c
|
|||
|
a5b7093e32
|
4
Makefile
4
Makefile
@@ -20,6 +20,10 @@ docker-publish:
|
|||||||
release:
|
release:
|
||||||
kubectl --namespace devstats-viewer set image deployment devstats-viewer web=rg.fr-par.scw.cloud/averagemarcus/devstats-viewer:$(SHA)
|
kubectl --namespace devstats-viewer set image deployment devstats-viewer web=rg.fr-par.scw.cloud/averagemarcus/devstats-viewer:$(SHA)
|
||||||
|
|
||||||
|
.PHONY: run # Run the web server (relies on npx being available)
|
||||||
|
run:
|
||||||
|
npx http-server ./src
|
||||||
|
|
||||||
.PHONY: help # Show this list of commands
|
.PHONY: help # Show this list of commands
|
||||||
help:
|
help:
|
||||||
@echo "kube-image-prefetch"
|
@echo "kube-image-prefetch"
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -1,3 +1,11 @@
|
|||||||
# devstats-viewer
|
# devstats-viewer
|
||||||
|
|
||||||
Discover your CNCF devstats score based on your GitHub username
|
Discover your CNCF devstats score based on your GitHub username.
|
||||||
|
|
||||||
|
Thanks to the [DevStats Code](https://github.com/cncf/devstatscode) authors for providing the API that powers this.
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
|
||||||
|
* [DevStats](https://github.com/cncf/devstats)
|
||||||
|
* [Dashboards](https://devstats.cncf.io/)
|
||||||
|
* [DevStats Code](https://github.com/cncf/devstatscode)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
||||||
|
|
||||||
<title>Devstats!</title>
|
<title>DevStats!</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="/style.css" />
|
<link rel="stylesheet" href="/style.css" />
|
||||||
<script src="/script.js" defer></script>
|
<script src="/script.js" defer></script>
|
||||||
@@ -12,10 +12,10 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<div class="content" role="main">
|
<div class="content" role="main">
|
||||||
<h1 class="title">Devstats!</h1>
|
<h1 class="title">DevStats!</h1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Enter your GitHub username to find your CNCF devstats score.
|
Enter your GitHub username to find your <a href="https://cncf.io/">CNCF</a> devstats score.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
<div id="status"></div>
|
<div id="status"></div>
|
||||||
|
|
||||||
<div id="result"></div>
|
<div id="result"></div>
|
||||||
|
<div id="subResult"></div>
|
||||||
<details id="rawResultsWrapper" class="hidden">
|
<details id="rawResultsWrapper" class="hidden">
|
||||||
<summary>Raw results</summary>
|
<summary>Raw results</summary>
|
||||||
<pre id="rawResults"></pre>
|
<pre id="rawResults"></pre>
|
||||||
@@ -34,7 +35,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
Made with 💙 by <a href="https://marcusnoble.com">Marcus Noble</a>
|
<p>
|
||||||
|
Made with 💙 by <a href="https://marcusnoble.com">Marcus Noble</a> and with thanks to the <a href="https://github.com/cncf/devstatscode">DevStats code</a> authors
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Source available at:<br/>
|
||||||
|
<a href="https://github.com/AverageMarcus/devstats-viewer" target="_blank">https://github.com/AverageMarcus/devstats-viewer</a>
|
||||||
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,15 +1,26 @@
|
|||||||
const btn = document.querySelector("#find");
|
const btn = document.querySelector("#find");
|
||||||
const gh = document.querySelector("#github");
|
const gh = document.querySelector("#github");
|
||||||
const result = document.querySelector("#result");
|
const result = document.querySelector("#result");
|
||||||
|
const subResult = document.querySelector("#subResult");
|
||||||
const status = document.querySelector("#status");
|
const status = document.querySelector("#status");
|
||||||
|
|
||||||
const rawResultsWrapper = document.querySelector("#rawResultsWrapper");
|
const rawResultsWrapper = document.querySelector("#rawResultsWrapper");
|
||||||
const rawResults = document.querySelector("#rawResults");
|
const rawResults = document.querySelector("#rawResults");
|
||||||
|
|
||||||
|
// Parse URL query parameters
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const user = urlParams.get('user');
|
||||||
|
|
||||||
|
// Fill form with user parameter
|
||||||
|
if (user) {
|
||||||
|
gh.value = user;
|
||||||
|
find(); // Call the find function automatically
|
||||||
|
}
|
||||||
|
|
||||||
function find() {
|
function find() {
|
||||||
let user = gh.value.toLowerCase();
|
let user = gh.value.trim().toLowerCase();
|
||||||
if (user != "") {
|
if (user != "") {
|
||||||
statusUpdate(`Fetching devstat score for '${user}'`, "info");
|
statusUpdate(`Fetching devstats score for '${user}'`, "info");
|
||||||
rawResultsWrapper.classList.add('hidden');
|
rawResultsWrapper.classList.add('hidden');
|
||||||
fetch("https://devstats.cncf.io/api/v1", {
|
fetch("https://devstats.cncf.io/api/v1", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -19,24 +30,30 @@ function find() {
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
redirect: "follow",
|
redirect: "follow",
|
||||||
body: "{\"api\":\"DevActCnt\",\"payload\":{\"project\":\"all\",\"range\":\"Last decade\",\"metric\":\"Contributions\",\"repository_group\":\"All\",\"country\":\"All\",\"github_id\":\"" + user + "\",\"bg\":\"\"}}",
|
body: "{\"api\":\"GithubIDContributions\",\"payload\":{\"github_id\":\"" + user + "\"}}",
|
||||||
})
|
})
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
statusUpdate("", "info");
|
statusUpdate("", "info");
|
||||||
let score = data.number[0];
|
let score = data.contributions;
|
||||||
if (score) {
|
if (!score) {
|
||||||
|
statusUpdate(`Failed to get devstats score for '${user}'.\nEither user doesn't exist or no contributions recorded.`, "error");
|
||||||
|
}
|
||||||
result.innerHTML = score;
|
result.innerHTML = score;
|
||||||
|
subResult.innerHTML = `Issues: ${data.issues} | PRs: ${data.prs}`;
|
||||||
rawResults.innerText = JSON.stringify(data, "", 2)
|
rawResults.innerText = JSON.stringify(data, "", 2)
|
||||||
rawResultsWrapper.classList.remove('hidden');
|
rawResultsWrapper.classList.remove('hidden');
|
||||||
} else {
|
|
||||||
statusUpdate(`Failed to get devstat score for '${user}'`, "error");
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
statusUpdate(`Failed to get devstat score for '${user}'`, "error");
|
statusUpdate(`Failed to get devstats score for '${user}'`, "error");
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Change the URL
|
||||||
|
let url = new URL(window.location.href);
|
||||||
|
let params = new URLSearchParams(url.search);
|
||||||
|
params.set('user', user);
|
||||||
|
window.history.replaceState({}, '', `${url.pathname}?${params}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ html,
|
|||||||
body {
|
body {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@@ -43,6 +43,10 @@ body {
|
|||||||
color: var(--color-text-main);
|
color: var(--color-text-main);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: var(--color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
/* Page structure */
|
/* Page structure */
|
||||||
.wrapper {
|
.wrapper {
|
||||||
min-height: var(--wrapper-height);
|
min-height: var(--wrapper-height);
|
||||||
@@ -95,6 +99,7 @@ input {
|
|||||||
#status {
|
#status {
|
||||||
height: 22px;
|
height: 22px;
|
||||||
margin: 8px;
|
margin: 8px;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#status.info {
|
#status.info {
|
||||||
@@ -110,11 +115,30 @@ input {
|
|||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 70px;
|
font-size: 70px;
|
||||||
margin: 0.5em;
|
margin: 0.2em;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#rawResultsWrapper {
|
#subResult {
|
||||||
max-width: 90vw;
|
font-family: HK Grotesk;
|
||||||
overflow-x: scroll;
|
font-style: normal;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 20px;
|
||||||
|
margin: 0em;
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rawResultsWrapper {
|
||||||
|
margin-top: 2em;
|
||||||
|
overflow-x: scroll;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rawResultsWrapper summary {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rawResultsWrapper pre {
|
||||||
|
text-align: left;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user