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