spacehub

surshar / claude-code

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.

Built by Anthropic · github.com/anthropics

Merge pull request #5409 from anthropics/boris/cuxgBrowse files
Improve auto-close duplicates script pagination and filtering
Boris Cherny authored on Aug 8, 2025 · GitHub committed on Aug 8, 2025 parents 5248fa0 + eb48a37 · commit 483e0e892f10
1 changed file+27 -5compared with 5248fa0
Mscripts/auto-close-duplicates.ts
@@ -10,6 +10,7 @@
1010 number: number;
1111 title: string;
1212 user: { id: number };
13+ created_at: string;
1314 }
1415
1516 interface GitHubComment {
@@ -61,11 +62,32 @@
6162 `[DEBUG] Checking for duplicate comments older than: ${threeDaysAgo.toISOString()}`
6263 );
6364
64- console.log("[DEBUG] Fetching open issues...");
65- const issues: GitHubIssue[] = await githubRequest(
66- `/repos/${owner}/${repo}/issues?state=open&per_page=100`,
67- token
68- );
65+ console.log("[DEBUG] Fetching open issues created more than 3 days ago...");
66+ const allIssues: GitHubIssue[] = [];
67+ let page = 1;
68+ const perPage = 100;
69+
70+ while (true) {
71+ const pageIssues: GitHubIssue[] = await githubRequest(
72+ `/repos/${owner}/${repo}/issues?state=open&per_page=${perPage}&page=${page}`,
73+ token
74+ );
75+
76+ if (pageIssues.length === 0) break;
77+
78+ // Filter for issues created more than 3 days ago
79+ const oldEnoughIssues = pageIssues.filter(issue =>
80+ new Date(issue.created_at) <= threeDaysAgo
81+ );
82+
83+ allIssues.push(...oldEnoughIssues);
84+ page++;
85+
86+ // Safety limit to avoid infinite loops
87+ if (page > 20) break;
88+ }
89+
90+ const issues = allIssues;
6991 console.log(`[DEBUG] Found ${issues.length} open issues`);
7092
7193 let processedCount = 0;