Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Given an array with PR creation and approval times, compute the average duration
// run this query, for example in https://developer.github.com/v4/explorer/
// query MyQuery {
// repository(name: "repo-name", owner: "repo-owner") {
// pullRequests(states: MERGED, last: 100) {
// nodes {
// publishedAt
// reviews(first: 1, states:APPROVED) {
// nodes {
// submittedAt
// }
// }
// }
// }
// }
// }
// save the nested array of nodes in a variable named c, then:
c.filter(e => e.reviews.nodes[0])
.map(e => [e.publishedAt, e.reviews.nodes[0].submittedAt])
.map(e => [e[0], e[1], Date.parse(e[0]), Date.parse(e[1])])
.map(e => e.concat([e[3] - e[2]])).map(e => e.concat([e[4] / 1000 / 60 / 60]))
.map(e => e[5])
.reduce((acc, curr) => acc + curr) / (c.filter(e => e.reviews.nodes[0]).length)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.