-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsReferalCodeGenerator.js
More file actions
37 lines (30 loc) · 1.1 KB
/
Copy pathJsReferalCodeGenerator.js
File metadata and controls
37 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function generateReferralCode() {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
for (let i = 0; i < 8; i++) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
}
return result;
}
function generateReferralCodesBatch(batchSize) {
const referralCodes = [];
for (let i = 0; i < batchSize; i++) {
referralCodes.push(generateReferralCode());
}
return referralCodes;
}
function logReferralCodes(totalUsers) {
const batchSize = 10000;
let processedUsers = 0;
while (processedUsers < totalUsers) {
const remainingUsers = totalUsers - processedUsers;
const currentBatchSize = Math.min(batchSize, remainingUsers);
const referralCodes = generateReferralCodesBatch(currentBatchSize);
console.log(`Batch ${processedUsers / batchSize + 1}:`);
referralCodes.forEach((code, index) => {
console.log(`${processedUsers + index + 1}: ${code}`);
});
processedUsers += currentBatchSize;
}
}
logReferralCodes(10000000);