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
feat: update dedupe backfill script to filter by issue number
| @@ -82,46 +82,61 @@ | ||
| 82 | 82 | Environment Variables: |
| 83 | 83 | GITHUB_TOKEN - GitHub personal access token with repo and actions permissions (required) |
| 84 | 84 | DRY_RUN - Set to "false" to actually trigger workflows (default: true for safety) |
| 85 | - DAYS_BACK - How many days back to look for old issues (default: 90)`); | |
| 85 | + MAX_ISSUE_NUMBER - Only process issues with numbers less than this value (default: 4050)`); | |
| 86 | 86 | } |
| 87 | 87 | console.log("[DEBUG] GitHub token found"); |
| 88 | 88 | |
| 89 | 89 | const owner = "anthropics"; |
| 90 | 90 | const repo = "claude-code"; |
| 91 | 91 | const dryRun = process.env.DRY_RUN !== "false"; |
| 92 | - const daysBack = parseInt(process.env.DAYS_BACK || "90", 10); | |
| 92 | + const maxIssueNumber = parseInt(process.env.MAX_ISSUE_NUMBER || "4050", 10); | |
| 93 | + const minIssueNumber = parseInt(process.env.MIN_ISSUE_NUMBER || "1", 10); | |
| 93 | 94 | |
| 94 | 95 | console.log(`[DEBUG] Repository: ${owner}/${repo}`); |
| 95 | 96 | console.log(`[DEBUG] Dry run mode: ${dryRun}`); |
| 96 | - console.log(`[DEBUG] Looking back ${daysBack} days`); | |
| 97 | + console.log(`[DEBUG] Looking at issues between #${minIssueNumber} and #${maxIssueNumber}`); | |
| 97 | 98 | |
| 98 | - const cutoffDate = new Date(); | |
| 99 | - cutoffDate.setDate(cutoffDate.getDate() - daysBack); | |
| 100 | - | |
| 101 | - console.log(`[DEBUG] Fetching issues created since ${cutoffDate.toISOString()}...`); | |
| 99 | + console.log(`[DEBUG] Fetching issues between #${minIssueNumber} and #${maxIssueNumber}...`); | |
| 102 | 100 | const allIssues: GitHubIssue[] = []; |
| 103 | 101 | let page = 1; |
| 104 | 102 | const perPage = 100; |
| 105 | 103 | |
| 106 | 104 | while (true) { |
| 107 | 105 | const pageIssues: GitHubIssue[] = await githubRequest( |
| 108 | - `/repos/${owner}/${repo}/issues?state=all&per_page=${perPage}&page=${page}&since=${cutoffDate.toISOString()}`, | |
| 106 | + `/repos/${owner}/${repo}/issues?state=all&per_page=${perPage}&page=${page}&sort=created&direction=desc`, | |
| 109 | 107 | token |
| 110 | 108 | ); |
| 111 | 109 | |
| 112 | 110 | if (pageIssues.length === 0) break; |
| 113 | 111 | |
| 114 | - allIssues.push(...pageIssues); | |
| 112 | + // Filter to only include issues within the specified range | |
| 113 | + const filteredIssues = pageIssues.filter(issue => | |
| 114 | + issue.number >= minIssueNumber && issue.number < maxIssueNumber | |
| 115 | + ); | |
| 116 | + allIssues.push(...filteredIssues); | |
| 117 | + | |
| 118 | + // If the oldest issue in this page is still above our minimum, we need to continue | |
| 119 | + // but if the oldest issue is below our minimum, we can stop | |
| 120 | + const oldestIssueInPage = pageIssues[pageIssues.length - 1]; | |
| 121 | + if (oldestIssueInPage && oldestIssueInPage.number >= maxIssueNumber) { | |
| 122 | + console.log(`[DEBUG] Oldest issue in page #${page} is #${oldestIssueInPage.number}, continuing...`); | |
| 123 | + } else if (oldestIssueInPage && oldestIssueInPage.number < minIssueNumber) { | |
| 124 | + console.log(`[DEBUG] Oldest issue in page #${page} is #${oldestIssueInPage.number}, below minimum, stopping`); | |
| 125 | + break; | |
| 126 | + } else if (filteredIssues.length === 0 && pageIssues.length > 0) { | |
| 127 | + console.log(`[DEBUG] No issues in page #${page} are in range #${minIssueNumber}-#${maxIssueNumber}, continuing...`); | |
| 128 | + } | |
| 129 | + | |
| 115 | 130 | page++; |
| 116 | 131 | |
| 117 | 132 | // Safety limit to avoid infinite loops |
| 118 | - if (page > 100) { | |
| 133 | + if (page > 200) { | |
| 119 | 134 | console.log("[DEBUG] Reached page limit, stopping pagination"); |
| 120 | 135 | break; |
| 121 | 136 | } |
| 122 | 137 | } |
| 123 | 138 | |
| 124 | - console.log(`[DEBUG] Found ${allIssues.length} issues from the last ${daysBack} days`); | |
| 139 | + console.log(`[DEBUG] Found ${allIssues.length} issues between #${minIssueNumber} and #${maxIssueNumber}`); | |
| 125 | 140 | |
| 126 | 141 | let processedCount = 0; |
| 127 | 142 | let candidateCount = 0; |