forked from DebaucheryLibrarian/traxxx
Updated Jules Jordan scraper.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
const knex = require('../knex');
|
||||
const chunk = require('./chunk');
|
||||
const logger = require('../logger')(__filename);
|
||||
|
||||
async function bulkUpsert(table, items, conflict, update = true, chunkSize) {
|
||||
if (items.length === 0) {
|
||||
@@ -26,9 +27,14 @@ async function bulkUpsert(table, items, conflict, update = true, chunkSize) {
|
||||
query: knex(table).insert(chunkItems),
|
||||
}).transacting(transaction));
|
||||
|
||||
const responses = await Promise.all(queries);
|
||||
try {
|
||||
const responses = await Promise.all(queries);
|
||||
|
||||
return responses.flat().map((response) => response.rows).flat();
|
||||
return responses.flat().map((response) => response.rows).flat();
|
||||
} catch (error) {
|
||||
logger.error(`Failed bulk insert: ${error.message} (${error.detail})`);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user