Skip to content

Commit

Permalink
tweak load dids
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Nov 9, 2023
1 parent 86ca769 commit 9bf2fa9
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/pds/src/migrate-script/load-dids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,31 @@ import { setupEnv } from './util'

const run = async () => {
const amount = parseInt(process.argv[2])
const pdsId = parseInt(process.argv[3])
console.log(`loading next ${amount} dids`)
const { db, ctx } = await setupEnv()

const lastDidInDb = await db
.selectFrom('status')
.select('did')
.orderBy('did', 'desc')
.limit(1)
.executeTakeFirst()

const lastDid = lastDidInDb?.did ?? ''

const didsRes = await ctx.db.db
.selectFrom('user_account')
.select('did')
.where('pdsId', 'is', null)
.where('did', '>', lastDid)
.orderBy('did', 'asc')
.limit(amount)
.execute()
const dids = didsRes.map((row, i) => ({
const dids = didsRes.map((row) => ({
did: row.did,
phase: 0,
pdsId: (i % 2) + 1,
pdsId,
failed: 0 as const,
}))

Expand Down

0 comments on commit 9bf2fa9

Please sign in to comment.