Created
May 26, 2020 21:35
-
-
Save douglasnaphas/6bdec64b2cfce34f65cdcc452bf4de60 to your computer and use it in GitHub Desktop.
Given an array with PR creation and approval times, compute the average duration
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
// 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