Skip to content

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

TypeScript

Improve auto-close duplicates script pagination and filtering

Boris Chernyeb48a37a4869
diff --git a/scripts/auto-close-duplicates.ts b/scripts/auto-close-duplicates.ts
index 9985ba8c..1b358946 100644
--- a/scripts/auto-close-duplicates.ts
+++ b/scripts/auto-close-duplicates.ts
@@ -10,6 +10,7 @@ interface GitHubIssue {
number: number;
title: string;
user: { id: number };
+ created_at: string;
}
interface GitHubComment {
@@ -61,11 +62,32 @@ async function autoCloseDuplicates(): Promise<void> {
`[DEBUG] Checking for duplicate comments older than: ${threeDaysAgo.toISOString()}`
);
- console.log("[DEBUG] Fetching open issues...");
- const issues: GitHubIssue[] = await githubRequest(
- `/repos/${owner}/${repo}/issues?state=open&per_page=100`,
- token
- );
+ console.log("[DEBUG] Fetching open issues created more than 3 days ago...");
+ const allIssues: GitHubIssue[] = [];
+ let page = 1;
+ const perPage = 100;
+
+ while (true) {
+ const pageIssues: GitHubIssue[] = await githubRequest(
+ `/repos/${owner}/${repo}/issues?state=open&per_page=${perPage}&page=${page}`,
+ token
+ );
+
+ if (pageIssues.length === 0) break;
+
+ // Filter for issues created more than 3 days ago
+ const oldEnoughIssues = pageIssues.filter(issue =>
+ new Date(issue.created_at) <= threeDaysAgo
+ );
+
+ allIssues.push(...oldEnoughIssues);
+ page++;
+
+ // Safety limit to avoid infinite loops
+ if (page > 20) break;
+ }
+
+ const issues = allIssues;
console.log(`[DEBUG] Found ${issues.length} open issues`);
let processedCount = 0;