Skip to content

Instantly share code, notes, and snippets.

@BlairCurrey
Last active February 2, 2023 22:43
Show Gist options
  • Save BlairCurrey/d16ebc765e01f5a0f71944f9c6d56b37 to your computer and use it in GitHub Desktop.
Save BlairCurrey/d16ebc765e01f5a0f71944f9c6d56b37 to your computer and use it in GitHub Desktop.
Sums Codecov coverage changes by Github username on codecov.com
// navigate to https://app.codecov.io/gh/[ORG]/[REPO]/pulls?prStates%5B0%5D=MERGED
function sleep(delay) {
return new Promise(function(resolve) {
setTimeout(resolve, delay);
});
}
async function loadAll(){
while(true) {
await sleep(500);
btn = document.querySelectorAll('[data-testid="load-more"]');
if(!btn.length) break;
btn[0].click()
}
}
function getNetChangeByGithubUsername(){
let counts = {}
const rows = document.querySelectorAll('[data-testid="body-row"]')[0].childNodes;
Array.from(rows).forEach(row => {
const name = row.querySelector('td>div>div>p>a>span').innerHTML
// this might not contain the element with the value.
// Sometimes there is no span, just a div with "-" which we can ignore
const element = row.querySelector('td:nth-child(3)>div>span');
if(element){
// expecting innerHTML to be of form "1.00%", "-3.40%", etc.
change = Number(element.innerHTML.replace('%', ''));
// filter out same bad coverage changes.
// should not do this with a more reliable history.
if(Math.abs(change) < 1){
counts[name] = (counts[name] || 0) + change;
}
}
})
return counts
}
(async function() {
console.log('loading all ...')
await loadAll()
const netChangeByGithubUsername = getNetChangeByGithubUsername()
console.log({netChangeByGithubUsername})
console.log('done loading all')
}());
@BlairCurrey
Copy link
Author

BlairCurrey commented Feb 2, 2023

I saved this as a snippet (under "Sources" in chrome dev tools) and ran it at https://app.codecov.io/gh/[ORG]/[REPO]/pulls?prStates%5B0%5D=MERGED

Script sleeps for 500ms so it can take a while to run. Results log to console.

May need to adjust the sleep amount (go lower if possible) and lines that filter out "bad" (too big of) coverage changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment