Last active
July 30, 2020 14:46
-
-
Save bketelsen/8874aa0d36831c2ad0b3713623ab5d01 to your computer and use it in GitHub Desktop.
github activity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ghUserEvents = require('gh-user-events'); | |
var watches = 0; | |
var comments = 0; | |
var pushes = 0; | |
var prs = 0; | |
var createRepos = 0; | |
var deleteRepos = 0; | |
var reviews = 0; | |
var issues = 0; | |
const users = ['bketelsen', 'bnb']; | |
async function updateUsers(users) { | |
for (const user of users) { | |
await aggregate(user) | |
} | |
} | |
async function aggregate(user) { | |
await ghUserEvents(user, { maxPageSize: 1 }).then(events => { | |
events.forEach(countThem); | |
}); | |
} | |
function countThem(value, index, array) { | |
console.log(value.type); | |
console.log("\t ", index); | |
if (value.type === "WatchEvent") { | |
watches = watches + 1; | |
} | |
if (value.type === "PushEvent") { | |
pushes = pushes + 1; | |
} | |
if (value.type === "PullRequestEvent") { | |
prs = prs + 1; | |
} | |
if (value.type === "IssueCommentEvent") { | |
comments = comments + 1; | |
} | |
if (value.type === "PullRequestReviewCommentEvent") { | |
comments = comments + 1; | |
reviews = reviews + 1; | |
} | |
if (value.type === "IssuesEvent") { | |
issues = issues + 1; | |
} | |
} | |
function printValues() { | |
console.log("Watches:", watches); | |
console.log("Pushes:", pushes); | |
console.log("PRs:", prs); | |
console.log("Comments:", comments); | |
console.log("Issues", issues); | |
console.log("Reviews", reviews); | |
} | |
updateUsers(users).then(printValues()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment