File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { insertConfigEntriesForAdapter } from "../utils/adapter" ;
2
- import hyperlane , { build , getEvents } from "../adapters/hyperlane" ;
2
+ import { build , getEvents } from "../adapters/hyperlane" ;
3
3
import dayjs from "dayjs" ;
4
+ import _ from "lodash" ;
4
5
import { insertTransactionRows } from "../utils/wrappa/postgres/write" ;
5
6
import { getBridgeID } from "../utils/wrappa/postgres/query" ;
6
7
import { sql } from "../utils/db" ;
@@ -40,7 +41,11 @@ export const handler = async () => {
40
41
} ) ) ;
41
42
startTs = toTs ;
42
43
await sql . begin ( async ( sql ) => {
43
- await insertTransactionRows ( sql , true , transactions , "upsert" ) ;
44
+ const batchSize = 200 ;
45
+ const transactionChunks = _ . chunk ( transactions , batchSize ) ;
46
+ for ( const batch of transactionChunks ) {
47
+ await insertTransactionRows ( sql , true , batch , "upsert" ) ;
48
+ }
44
49
} ) ;
45
50
console . log ( `Inserted ${ transactions . length } transactions for ${ startTs } to ${ endTs } ` ) ;
46
51
}
@@ -49,4 +54,5 @@ export const handler = async () => {
49
54
throw error ;
50
55
}
51
56
} ;
57
+
52
58
export default handler ;
You can’t perform that action at this time.
0 commit comments