Skip to content

Commit

Permalink
feat: added reviewers to contribution list
Browse files Browse the repository at this point in the history
  • Loading branch information
tgetgood authored and RichardLitt committed Oct 20, 2017
1 parent 64bf01f commit d847cf2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 23 deletions.
3 changes: 3 additions & 0 deletions src/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ const executequery = (token, query, debugMode) => {
})
})
req.on('error', reject)
if (debugMode) {
console.log(formatQuery(query))
}
req.write(formatQuery(query))
req.end()
})
Expand Down
69 changes: 47 additions & 22 deletions src/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ const reactorQ = node('reactions', {first: 10})
.addChild(node('name'))
.addChild(node('url'))))

const reviewAuthoredQ = node('nodes')
.addChild(node('id'))
.addChild(node('author')
.addChild(node('login'))
.addChild(node('... on User')
.addChild(node('name'))
.addChild(node('url'))))
.addChild(node('createdAt'))

const authoredQ = node('nodes')
.addChild(reactorQ)
.addChild(node('id'))
Expand All @@ -30,17 +39,24 @@ const authoredQ = node('nodes')
.addChild(node('url'))))
.addChild(node('createdAt'))

const reviewPartQ = reviewAuthoredQ
.addChild(node('comments', {first: 20})
.addChild(pagination)
.addChild(reviewAuthoredQ))

const reviewQ = node('reviews', {first: 20})
.addChild(pagination)
.addChild(reviewPartQ)

const participantsQ = authoredQ
.addChild(node('comments', {first: 100})
.addChild(pagination)
.addChild(authoredQ))

const prsQ = node('pullRequests', {first: 100})
.addChild(pagination)
.addChild(participantsQ)
.addChild(node('reviews', {first: 20)
.addChild(paginations)
.addChild(participantsQ))
.addChild(participantsQ
.addChild(reviewQ))

const issuesQ = node('issues', {first: 100})
.addChild(pagination)
Expand Down Expand Up @@ -225,15 +241,23 @@ const cleanRepo = async (token, result, before, after) => {
query: commitCommentQ
})

const prCs = await depaginateAll(prs, {
const reviews = await depaginateAll(prs, {
token,
acc: pr => pr.reviews.nodes,
type: 'PullRequest',
key: 'reviews',
query: reviewPartQ
})

const prComments = await depaginateAll(prs, {
token,
acc: pr => pr.comments.nodes,
type: 'PullRequest',
key: 'comments',
query: authoredQ
})

const issueCs = await depaginateAll(issues, {
const issueComments = await depaginateAll(issues, {
token,
acc: issue => issue.comments.nodes,
type: 'Issue',
Expand All @@ -247,27 +271,28 @@ const cleanRepo = async (token, result, before, after) => {
type: 'CommitComment',
key: 'reactions',
query: reactorQ
})).concat(await depaginateAll(issueCs, {
token,
acc: ic => ic.reactions.nodes,
type: 'IssueComment',
key: 'reactions',
query: reactorQ
})).concat(await depaginateAll(prCs, {
token,
acc: prc => prc.reactions.nodes,
type: 'PullRequestComment',
key: 'reactions',
query: reactorQ
}))
})).concat(await depaginateAll(issueComments, {
token,
acc: ic => ic.reactions.nodes,
type: 'IssueComment',
key: 'reactions',
query: reactorQ
})).concat(await depaginateAll(prComments, {
token,
acc: prc => prc.reactions.nodes,
type: 'PullRequestComment',
key: 'reactions',
query: reactorQ
}))

return {
commitCommentators: process(commitComments),
prCreators: process(prs),
prCommentators: process(prCs),
prCommentators: process(prComments),
issueCreators: process(issues),
issueCommentators: process(issueCs),
reactors: process(reactions)
issueCommentators: process(issueComments),
reactors: process(reactions),
reviewers: process(reviews)
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const emptyResponse = {
prCreators: [],
prCommentators: [],
issueCreators: [],
issueCommentators: []
issueCommentators: [],
reviewers: []
}

test('No contributions in a single second', t => {
Expand Down

0 comments on commit d847cf2

Please sign in to comment.