From 704a9c3faf3fb5c2ea87b0e0f2e0e3db235a9fbc Mon Sep 17 00:00:00 2001 From: dholms Date: Wed, 8 Nov 2023 19:15:32 -0600 Subject: [PATCH] round robin dids --- packages/pds/src/migrate-script/load-dids.ts | 13 ++++++------- packages/pds/src/migrate-script/migrate-all.ts | 3 ++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/pds/src/migrate-script/load-dids.ts b/packages/pds/src/migrate-script/load-dids.ts index 56e561fb772..6fd69fa5528 100644 --- a/packages/pds/src/migrate-script/load-dids.ts +++ b/packages/pds/src/migrate-script/load-dids.ts @@ -13,13 +13,12 @@ const run = async () => { .orderBy('did', 'asc') .limit(amount) .execute() - const dids = didsRes - .map((row) => ({ - did: row.did, - phase: 0, - failed: 0 as const, - })) - .filter((row) => row.did.length > 2) + const dids = didsRes.map((row, i) => ({ + did: row.did, + phase: 0, + pdsId: (i % 2) + 1, + failed: 0 as const, + })) await Promise.all( chunkArray(dids, 50).map((chunk) => diff --git a/packages/pds/src/migrate-script/migrate-all.ts b/packages/pds/src/migrate-script/migrate-all.ts index 428ebe7b7eb..42dafca54db 100644 --- a/packages/pds/src/migrate-script/migrate-all.ts +++ b/packages/pds/src/migrate-script/migrate-all.ts @@ -23,6 +23,7 @@ export const runScript = async () => { const todo = await db .selectFrom('status') .where('status.phase', '<', 7) + .where('failed', '=', 0) .orderBy('phase', 'desc') .orderBy('did') .selectAll() @@ -33,7 +34,7 @@ export const runScript = async () => { console.log('migrating: ', todo.length) - const migrateQueue = new PQueue({ concurrency: 80 }) + const migrateQueue = new PQueue({ concurrency: 150 }) process.on('SIGINT', async () => { migrateQueue.clear() console.log(`waiting on ${migrateQueue.pending} to finish`)