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:
|
||||
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
|
||||
help:
|
||||
@echo "kube-image-prefetch"
|
||||
|
||||
10
README.md
10
README.md
@@ -1,3 +1,11 @@
|
||||
# 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 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" />
|
||||
<script src="/script.js" defer></script>
|
||||
@@ -12,20 +12,21 @@
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="content" role="main">
|
||||
<h1 class="title">Devstats!</h1>
|
||||
|
||||
<h1 class="title">DevStats!</h1>
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
<div>
|
||||
<label>GitHub Username: <input name="github" id="github" autocomplete="off" data-lpignore="true" /></label>
|
||||
<button id="find">Find</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="status"></div>
|
||||
|
||||
|
||||
<div id="result"></div>
|
||||
<div id="subResult"></div>
|
||||
<details id="rawResultsWrapper" class="hidden">
|
||||
<summary>Raw results</summary>
|
||||
<pre id="rawResults"></pre>
|
||||
@@ -34,7 +35,13 @@
|
||||
</div>
|
||||
|
||||
<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>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,15 +1,26 @@
|
||||
const btn = document.querySelector("#find");
|
||||
const gh = document.querySelector("#github");
|
||||
const result = document.querySelector("#result");
|
||||
const subResult = document.querySelector("#subResult");
|
||||
const status = document.querySelector("#status");
|
||||
|
||||
const rawResultsWrapper = document.querySelector("#rawResultsWrapper");
|
||||
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() {
|
||||
let user = gh.value.toLowerCase();
|
||||
let user = gh.value.trim().toLowerCase();
|
||||
if (user != "") {
|
||||
statusUpdate(`Fetching devstat score for '${user}'`, "info");
|
||||
statusUpdate(`Fetching devstats score for '${user}'`, "info");
|
||||
rawResultsWrapper.classList.add('hidden');
|
||||
fetch("https://devstats.cncf.io/api/v1", {
|
||||
method: "POST",
|
||||
@@ -19,24 +30,30 @@ function find() {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
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(data => {
|
||||
statusUpdate("", "info");
|
||||
let score = data.number[0];
|
||||
if (score) {
|
||||
result.innerHTML = score;
|
||||
rawResults.innerText = JSON.stringify(data, "", 2)
|
||||
rawResultsWrapper.classList.remove('hidden');
|
||||
} else {
|
||||
statusUpdate(`Failed to get devstat score for '${user}'`, "error");
|
||||
let score = data.contributions;
|
||||
if (!score) {
|
||||
statusUpdate(`Failed to get devstats score for '${user}'.\nEither user doesn't exist or no contributions recorded.`, "error");
|
||||
}
|
||||
result.innerHTML = score;
|
||||
subResult.innerHTML = `Issues: ${data.issues} | PRs: ${data.prs}`;
|
||||
rawResults.innerText = JSON.stringify(data, "", 2)
|
||||
rawResultsWrapper.classList.remove('hidden');
|
||||
})
|
||||
.catch(err => {
|
||||
statusUpdate(`Failed to get devstat score for '${user}'`, "error");
|
||||
statusUpdate(`Failed to get devstats score for '${user}'`, "error");
|
||||
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}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,4 +69,4 @@ gh.onkeypress = function(event) {
|
||||
}
|
||||
}
|
||||
|
||||
btn.onclick = find;
|
||||
btn.onclick = find;
|
||||
|
||||
@@ -34,7 +34,7 @@ html,
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
body {
|
||||
@@ -43,6 +43,10 @@ body {
|
||||
color: var(--color-text-main);
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
/* Page structure */
|
||||
.wrapper {
|
||||
min-height: var(--wrapper-height);
|
||||
@@ -95,6 +99,7 @@ input {
|
||||
#status {
|
||||
height: 22px;
|
||||
margin: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#status.info {
|
||||
@@ -110,11 +115,30 @@ input {
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
font-size: 70px;
|
||||
margin: 0.5em;
|
||||
margin: 0.2em;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
#subResult {
|
||||
font-family: HK Grotesk;
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
font-size: 20px;
|
||||
margin: 0em;
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
#rawResultsWrapper {
|
||||
max-width: 90vw;
|
||||
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