Skip to content

Commit 42dcb2b

Browse files
committed
feat: batch languages in groups of ten
1 parent 00cb7ae commit 42dcb2b

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

src/index.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,25 @@ async function queueLanguages() {
7171
}
7272

7373
const sqsClient = new SQSClient();
74-
await sqsClient.send(
75-
new SendMessageBatchCommand({
76-
QueueUrl: process.env.GITHUB_EXPORT_QUEUE_URL,
77-
Entries: languages.map((language) => ({
78-
MessageGroupId: "github-export",
79-
Id: language.code,
80-
MessageBody: JSON.stringify({
81-
code: language.code,
74+
const batches = [];
75+
for (let i = 0; i < languages.length; i += 10) {
76+
batches.push(
77+
sqsClient.send(
78+
new SendMessageBatchCommand({
79+
QueueUrl: process.env.GITHUB_EXPORT_QUEUE_URL,
80+
Entries: languages.slice(i, i + 10).map((language) => ({
81+
MessageGroupId: "github-export",
82+
Id: language.code,
83+
MessageBody: JSON.stringify({
84+
code: language.code,
85+
}),
86+
})),
8287
}),
83-
})),
84-
}),
85-
);
88+
),
89+
);
90+
}
91+
92+
await Promise.allSettled(batches);
8693

8794
console.log(`Queued the following languages for export to GitHub:
8895
${languages.map((language) => language.code).join("\n")}`);

0 commit comments

Comments
 (0)