Skip to content

Commit

Permalink
fix: collecting issue and pr reactions
Browse files Browse the repository at this point in the history
Was previously only collecting comment reactions from prs and issues,
not reactions to the issues and prs themselves.
  • Loading branch information
tgetgood authored and RichardLitt committed Oct 20, 2017
1 parent d847cf2 commit a322aec
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,7 @@ 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'))
.addChild(node('author')
.addChild(node('login'))
Expand All @@ -39,19 +29,17 @@ const authoredQ = node('nodes')
.addChild(node('url'))))
.addChild(node('createdAt'))

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

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

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

const prsQ = node('pullRequests', {first: 100})
.addChild(pagination)
Expand Down Expand Up @@ -246,23 +234,23 @@ const cleanRepo = async (token, result, before, after) => {
acc: pr => pr.reviews.nodes,
type: 'PullRequest',
key: 'reviews',
query: reviewPartQ
query: authoredQ
})

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

const issueComments = await depaginateAll(issues, {
token,
acc: issue => issue.comments.nodes,
type: 'Issue',
key: 'comments',
query: authoredQ
query: authoredQ.addChild(reactorQ)
})

const reactions = Array.from(await depaginateAll(commitComments, {
Expand All @@ -283,6 +271,18 @@ const cleanRepo = async (token, result, before, after) => {
type: 'PullRequestComment',
key: 'reactions',
query: reactorQ
})).concat(await depaginateAll(issues, {
token,
acc: is => is.reactions.nodes,
type: 'Issue',
key: 'reactions',
query: participantsQ
})).concat(await depaginateAll(prs, {
token,
acc: pr => pr.reactions.nodes,
type: 'PullRequest',
key: 'reactions',
query: participantsQ
}))

return {
Expand Down

0 comments on commit a322aec

Please sign in to comment.