Last active
July 30, 2020 14:29
-
-
Save bnb/d4fd7ddc82e15188fab2bd9b1f066648 to your computer and use it in GitHub Desktop.
rip
This file contains 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) { | |
users.forEach( | |
user => await aggregate(user) | |
); | |
} | |
console.log("Watches:", watches); | |
console.log("Pushes:", pushes); | |
console.log("PRs:", prs); | |
console.log("Comments:", comments); | |
console.log("Issues", issues); | |
console.log("Reviews", reviews); | |
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment