Skip to content

Commit 02b7fa7

Browse files
committed
fix: reduce rate limit sleep duration and improve discussion processing efficiency
1 parent e5b6475 commit 02b7fa7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/copy-discussions.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727

2828
// Configuration
2929
const INCLUDE_POLL_MERMAID_CHART = true; // Set to false to disable Mermaid pie chart for polls
30-
const RATE_LIMIT_SLEEP_SECONDS = 2; // Default sleep duration between API calls to avoid rate limiting
30+
const RATE_LIMIT_SLEEP_SECONDS = 0.5; // Default sleep duration between API calls to avoid rate limiting
31+
const DISCUSSION_PROCESSING_DELAY_SECONDS = 5; // Delay between processing discussions
3132

3233
const { Octokit } = require("octokit");
3334

@@ -693,7 +694,7 @@ async function createDiscussion(octokit, repositoryId, categoryId, title, body,
693694

694695
log(`Creating discussion: '${title}'`);
695696

696-
await rateLimitSleep(3);
697+
await rateLimitSleep();
697698

698699
try {
699700
const response = await octokit.graphql(CREATE_DISCUSSION_MUTATION, {
@@ -924,7 +925,7 @@ async function copyDiscussionComments(octokit, discussionId, comments, answerCom
924925
async function processDiscussionsPage(sourceOctokit, targetOctokit, owner, repo, targetRepoId, targetCategories, targetLabels, cursor = null) {
925926
log(`Fetching discussions page (cursor: ${cursor || "null"})...`);
926927

927-
await rateLimitSleep(3);
928+
await rateLimitSleep();
928929

929930
try {
930931
const response = await sourceOctokit.graphql(FETCH_DISCUSSIONS_QUERY, {
@@ -1050,7 +1051,7 @@ async function processDiscussionsPage(sourceOctokit, targetOctokit, owner, repo,
10501051
log(`✅ Finished processing discussion #${discussion.number}: '${discussion.title}'`);
10511052

10521053
// Delay between discussions
1053-
await sleep(5);
1054+
await sleep(DISCUSSION_PROCESSING_DELAY_SECONDS);
10541055

10551056
} catch (err) {
10561057
error(`Failed to create discussion #${discussion.number}: '${discussion.title}' - ${err.message}`);

0 commit comments

Comments
 (0)