Add offset and limit in pereparation for the large dataset

This commit is contained in:
William Jeynes
2026-04-05 22:47:25 +01:00
parent 00d129bd28
commit 75ca1032a6
3 changed files with 16 additions and 5 deletions
+14 -2
View File
@@ -19,6 +19,9 @@ const MODE = process.env.MODE ?? "claim";
const MAX_CONCURRENCY = 5;
const OFFSET = parseInt(process.env.OFFSET ?? "0", 10);
const LIMIT = process.env.LIMIT ? parseInt(process.env.LIMIT, 10) : null;
const client = new Client({ apiUrl: API_URL });
@@ -164,10 +167,19 @@ async function processRecord(record: any): Promise<ResultRecord> {
async function main() {
console.log("Reading input file...");
const records = await loadInputs();
const allRecords = await loadInputs();
console.log(`Loaded ${records.length} records`);
console.log(`Loaded ${allRecords.length} records`);
const records = allRecords.slice(
OFFSET,
LIMIT !== null ? OFFSET + LIMIT : undefined
);
console.log(
`Processing ${records.length} records (offset=${OFFSET}, limit=${LIMIT ?? "∞"})`
);
fs.writeFileSync(OUTPUT_FILE, "", { flag: "a" });
const limit = pLimit(MAX_CONCURRENCY);