master
1import { task } from '../../task.js'
2import { paginate } from '../../utils.js'
3import { IssueCommentsQuery } from './comments.graphql.js'
4
5export default task({
6 name: 'issue-comments' as const,
7 run: async ({ octokit, data, batch }, { username }: { username: string }) => {
8 const issueComments = paginate(octokit, IssueCommentsQuery, {
9 login: username,
10 })
11
12 data.issueComments = []
13
14 const batchReactions = batch('reactions-issue-comments', 'reactions-batch')
15
16 for await (const resp of issueComments) {
17 if (!resp.user?.issueComments.nodes) {
18 throw new Error('Failed to load issue comments')
19 }
20
21 for (const comment of resp.user.issueComments.nodes) {
22 data.issueComments.push(comment)
23 batchReactions(comment.reactionsTotal.totalCount, comment.id)
24 }
25
26 octokit.log.info(
27 `| issue comments ${data.issueComments.length}/${resp.user.issueComments.totalCount} (cost: ${resp.rateLimit?.cost}, remaining: ${resp.rateLimit?.remaining})`,
28 )
29 }
30 },
31})