Update .github/scripts/auto-close-duplicates.mjs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
19
.github/scripts/auto-close-duplicates.mjs
vendored
19
.github/scripts/auto-close-duplicates.mjs
vendored
@@ -82,9 +82,12 @@ async function autoCloseDuplicates() {
|
|||||||
let page = 1;
|
let page = 1;
|
||||||
const perPage = 100;
|
const perPage = 100;
|
||||||
|
|
||||||
|
const MAX_PAGES = 50; // Increase limit for larger repos
|
||||||
|
let foundRecentIssue = false;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const pageIssues = await githubRequest(
|
const pageIssues = await githubRequest(
|
||||||
`/repos/${owner}/${repo}/issues?state=open&per_page=${perPage}&page=${page}`,
|
`/repos/${owner}/${repo}/issues?state=open&per_page=${perPage}&page=${page}&sort=created&direction=desc`,
|
||||||
token
|
token
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -96,10 +99,22 @@ async function autoCloseDuplicates() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
allIssues.push(...oldEnoughIssues);
|
allIssues.push(...oldEnoughIssues);
|
||||||
|
|
||||||
|
// If all issues on this page are newer than 3 days, we can stop
|
||||||
|
if (oldEnoughIssues.length === 0 && page === 1) {
|
||||||
|
foundRecentIssue = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we found some old issues but not all, continue to next page
|
||||||
|
// as there might be more old issues
|
||||||
page++;
|
page++;
|
||||||
|
|
||||||
// Safety limit to avoid infinite loops
|
// Safety limit to avoid infinite loops
|
||||||
if (page > 20) break;
|
if (page > MAX_PAGES) {
|
||||||
|
console.log(`[WARNING] Reached maximum page limit of ${MAX_PAGES}`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const issues = allIssues;
|
const issues = allIssues;
|
||||||
|
|||||||
Reference in New Issue
Block a user