Skip to content

Instantly share code, notes, and snippets.

@bketelsen
Last active July 30, 2020 14:46
Show Gist options
  • Save bketelsen/8874aa0d36831c2ad0b3713623ab5d01 to your computer and use it in GitHub Desktop.
Save bketelsen/8874aa0d36831c2ad0b3713623ab5d01 to your computer and use it in GitHub Desktop.
github activity
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