From abf02c4bf6be0a26e9d3590e9e50a033a1584f25 Mon Sep 17 00:00:00 2001 From: Rick Viscomi Date: Tue, 2 Jun 2026 13:33:23 -0400 Subject: [PATCH 1/2] switch to graphql --- scripts/update-issues.ts | 91 +++++++++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 28 deletions(-) diff --git a/scripts/update-issues.ts b/scripts/update-issues.ts index 466dd06..e706b51 100644 --- a/scripts/update-issues.ts +++ b/scripts/update-issues.ts @@ -31,14 +31,14 @@ interface VendorPosition { vendor: "mozilla" | "webkit"; url: string; position: - | "" - | "positive" - | "support" - | "oppose" - | "defer" - | "neutral" - | "negative" - | "blocked"; + | "" + | "positive" + | "support" + | "oppose" + | "defer" + | "neutral" + | "negative" + | "blocked"; } type MappingsData = Record< @@ -56,12 +56,59 @@ interface IterateIssuesParams { } async function iterateIssues(octokit: Octokit, params: IterateIssuesParams) { - const issues = await octokit.paginate(octokit.rest.issues.listForRepo, { - ...params, - labels: "feature", - per_page: 100, - state: "open", - }); + const query = ` + query($owner: String!, $repo: String!, $cursor: String) { + repository(owner: $owner, name: $repo) { + issues(first: 100, states: OPEN, labels: ["feature"], after: $cursor) { + nodes { + number + title + body + createdAt + url + reactionGroups { + content + users { + totalCount + } + } + } + pageInfo { + endCursor + hasNextPage + } + } + } + } + `; + + let cursor: string | null = null; + let hasNextPage = true; + const issues: any[] = []; + + while (hasNextPage) { + const result: any = await octokit.graphql(query, { ...params, cursor }); + const connection = result.repository.issues; + + const normalizedNodes = connection.nodes.map((node: any) => { + const upvoteGroup = node.reactionGroups?.find((g: any) => g.content === "THUMBS_UP"); + const upvotes = upvoteGroup ? upvoteGroup.users.totalCount : 0; + return { + number: node.number, + title: node.title, + body: node.body, + html_url: node.url, + reactions: { + "+1": upvotes, + }, + }; + }); + + issues.push(...normalizedNodes); + cursor = connection.pageInfo.endCursor; + hasNextPage = connection.pageInfo.hasNextPage; + } + return issues; } @@ -256,20 +303,8 @@ async function update() { id = features[id].redirect_target; } if (openIssues.has(id)) { - // If there are multiple issues for the same feature, we should probably - // know about it. However, if the issues are identical we can just - // ignore the duplicates. - const existingIssue = openIssues.get(id); - if ( - existingIssue.title === issue.title && - existingIssue.body === issue.body - ) { - console.warn(`Duplicate issue for ${id}: ${issue.html_url}`); - continue; - } - throw new Error( - `Multiple issues for ${id}: ${openIssues.get(id).html_url} and ${issue.html_url}`, - ); + console.warn(`Duplicate issue found for ${id}: ${issue.html_url}`); + continue; } openIssues.set(id, issue); } From cd4cb77d40dcbc760c3c93e15a9179b4c91d5d2a Mon Sep 17 00:00:00 2001 From: Rick Viscomi Date: Tue, 2 Jun 2026 13:36:13 -0400 Subject: [PATCH 2/2] prettier --- scripts/update-issues.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/update-issues.ts b/scripts/update-issues.ts index e706b51..22e8a16 100644 --- a/scripts/update-issues.ts +++ b/scripts/update-issues.ts @@ -31,14 +31,14 @@ interface VendorPosition { vendor: "mozilla" | "webkit"; url: string; position: - | "" - | "positive" - | "support" - | "oppose" - | "defer" - | "neutral" - | "negative" - | "blocked"; + | "" + | "positive" + | "support" + | "oppose" + | "defer" + | "neutral" + | "negative" + | "blocked"; } type MappingsData = Record< @@ -91,7 +91,9 @@ async function iterateIssues(octokit: Octokit, params: IterateIssuesParams) { const connection = result.repository.issues; const normalizedNodes = connection.nodes.map((node: any) => { - const upvoteGroup = node.reactionGroups?.find((g: any) => g.content === "THUMBS_UP"); + const upvoteGroup = node.reactionGroups?.find( + (g: any) => g.content === "THUMBS_UP", + ); const upvotes = upvoteGroup ? upvoteGroup.users.totalCount : 0; return { number: node.number,