Skip to content

Commit

Permalink
improved transform logging
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Jun 16, 2024
1 parent 9bdfc99 commit a826ce0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 11 additions & 6 deletions src/queues/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export class TransformationsQueue extends BaseQueue<TransformationsQueuePayload>
throw new Error('no contract address nor code ID filter provided')
} else {
console.log(
`transforming events for contract addresses: ${addresses?.join(
', '
)} and code IDs: ${codeIds.join(', ')}`
`transforming events for contract addresses: ${
addresses?.join(', ') || '<any>'
} and code IDs: ${codeIds.length > 0 ? codeIds.join(', ') : '<any>'}`
)
}

Expand Down Expand Up @@ -110,6 +110,11 @@ export class TransformationsQueue extends BaseQueue<TransformationsQueuePayload>
let processed = 0
let transformed = 0

const logState = () =>
console.log(
`transformed/processed/total: ${transformed.toLocaleString()}/${processed.toLocaleString()}/${total.toLocaleString()}. latest block height: ${latestBlockHeight.toLocaleString()}`
)

let latestBlockEventIdsSeen: number[] = []
while (processed < total) {
const events = await WasmStateEvent.findAll({
Expand Down Expand Up @@ -172,11 +177,11 @@ export class TransformationsQueue extends BaseQueue<TransformationsQueuePayload>

transformed += transformations.length

console.log(
`transformed/processed/total: ${transformed.toLocaleString()}/${processed.toLocaleString()}/${total.toLocaleString()}. latest block height: ${latestBlockHeight.toLocaleString()}`
)
logState()
}

logState()

console.log('done!')
}
}
4 changes: 0 additions & 4 deletions src/scripts/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ const main = async () => {
codeIdsKeys,
} = program.opts()

console.log(`\n[${new Date().toISOString()}] Transforming existing events...`)

// Load config with config option.
const config = loadConfig(_config)

Expand All @@ -73,8 +71,6 @@ const main = async () => {
},
} as any)

console.log(`\n[${new Date().toISOString()}] Transforming complete.`)

await sequelize.close()

process.exit(0)
Expand Down

0 comments on commit a826ce0

Please sign in to comment.