Skip to content

Instantly share code, notes, and snippets.

@shibulijack-fd
Created January 22, 2020 08:35
Show Gist options
  • Save shibulijack-fd/b62786109d4894071971e2de2e9642c0 to your computer and use it in GitHub Desktop.
Save shibulijack-fd/b62786109d4894071971e2de2e9642c0 to your computer and use it in GitHub Desktop.
Github stats
const Octokit = require("@octokit/rest");
const octokit = Octokit({
auth: "GITHUB_AUTH_TOKEN",
userAgent: "gh-performyard v1.0.0",
baseUrl: "https://api.github.com"
});
const owner = "freshdesk";
const repo = "nucleus";
octokit.pulls
.list({
owner,
repo,
state: "closed",
base: "master",
sort: "created"
})
.then(({ data, headers, status }) => {
let pulls = data;
console.log(`Total number of PRs: ${pulls.length}`);
pulls.length &&
pulls.forEach(pr => {
console.log(`PR ${pr.number}`);
console.log(`TITLE: ${pr.title}`);
console.log(`DESCRIPTION: ${pr.body}`);
console.log(`=================================`);
});
});
octokit.activity
.listRepoEvents({
owner,
repo
})
.then(({ data, headers, status }) => {
let activities = data;
let reviewCount = 0;
activities.length &&
activities.forEach(activity => {
if (activity.actor && activity.actor === owner) {
reviewCount += 1;
}
});
console.log(`Total number of PR reviews: ${reviewCount}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment