Created
July 6, 2020 08:57
-
-
Save Naturalclar/7fc88ecca94a4f20e6e7d5839da6dca2 to your computer and use it in GitHub Desktop.
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
/** | |
* Original Author: @leko https://github.com/leko | |
*/ | |
const _ = require("lodash"); | |
const toSlug = (repo) => repo.nameWithOwner; | |
const obj = { | |
/** | |
* github の graphql api の結果を入れる。 | |
* 今回使ったquery は | |
* { | |
user(login: "Naturalclar") { | |
contributionsCollection(from: "2020-04-01T00:00:00.000Z", to: "2020-06-30T23:59:59.000Z") { | |
startedAt | |
endedAt | |
commitContributionsByRepository { | |
contributions { | |
totalCount | |
} | |
repository { | |
nameWithOwner | |
owner { | |
login | |
} | |
} | |
} | |
issueContributionsByRepository { | |
contributions { | |
totalCount | |
} | |
repository { | |
nameWithOwner | |
owner { | |
login | |
} | |
} | |
} | |
pullRequestContributionsByRepository { | |
contributions { | |
totalCount | |
} | |
repository { | |
nameWithOwner | |
owner { | |
login | |
} | |
} | |
} | |
pullRequestReviewContributionsByRepository { | |
contributions { | |
totalCount | |
} | |
repository { | |
nameWithOwner | |
owner { | |
login | |
} | |
} | |
} | |
} | |
} | |
} | |
*/ | |
}; | |
const { | |
pullRequestReviewContributionsByRepository, | |
pullRequestContributionsByRepository, | |
issueContributionsByRepository, | |
commitContributionsByRepository, | |
startedAt, | |
endedAt, | |
} = obj.data.user.contributionsCollection; | |
console.log("# Contributions by", obj.data.user.login); | |
console.log("Date:", startedAt, "~", endedAt); | |
console.log("\n## レビュー"); | |
_.sortBy( | |
pullRequestReviewContributionsByRepository, | |
({ repository }) => repository.nameWithOwner, | |
({ contributions }) => contributions.totalCount | |
).forEach(({ repository, contributions }) => { | |
console.log( | |
"- ", | |
toSlug(repository), | |
"->", | |
contributions.totalCount === 100 ? "100+" : contributions.totalCount, | |
"件" | |
); | |
}); | |
console.log("\n## プルリク"); | |
_.sortBy( | |
pullRequestContributionsByRepository, | |
({ repository }) => repository.nameWithOwner, | |
({ contributions }) => contributions.totalCount | |
).forEach(({ repository, contributions }) => { | |
console.log( | |
"- ", | |
toSlug(repository), | |
"->", | |
contributions.totalCount === 100 ? "100+" : contributions.totalCount, | |
"件" | |
); | |
}); | |
console.log("\n## Issue"); | |
_.sortBy( | |
issueContributionsByRepository, | |
({ repository }) => repository.nameWithOwner, | |
({ contributions }) => contributions.totalCount | |
).forEach(({ repository, contributions }) => { | |
console.log( | |
"- ", | |
toSlug(repository), | |
"->", | |
contributions.totalCount === 100 ? "100+" : contributions.totalCount, | |
"件" | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment