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
- Add pagination to fetch more than 100 issues (up to 20 pages/2000 issues) - Filter to only process issues created more than 3 days ago - Add created_at field to GitHubIssue interface 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
| @@ -10,6 +10,7 @@ | ||
| 10 | 10 | number: number; |
| 11 | 11 | title: string; |
| 12 | 12 | user: { id: number }; |
| 13 | + created_at: string; | |
| 13 | 14 | } |
| 14 | 15 | |
| 15 | 16 | interface GitHubComment { |
| @@ -61,11 +62,32 @@ | ||
| 61 | 62 | `[DEBUG] Checking for duplicate comments older than: ${threeDaysAgo.toISOString()}` |
| 62 | 63 | ); |
| 63 | 64 | |
| 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; | |
| 69 | 91 | console.log(`[DEBUG] Found ${issues.length} open issues`); |
| 70 | 92 | |
| 71 | 93 | let processedCount = 0; |