[chore] added small delay to sync-prices to not be too aggressive
This commit is contained in:
@@ -12,6 +12,10 @@ const DollarToInt = (dollar: any) => {
|
||||
return Math.round(dollar * 100);
|
||||
}
|
||||
|
||||
function sleep(ms: number) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
async function resetProcessingTable() {
|
||||
// Use sql.raw to execute the TRUNCATE TABLE statement
|
||||
await db.execute(sql.raw('TRUNCATE TABLE processingSkus;'));
|
||||
@@ -80,6 +84,8 @@ async function syncPrices() {
|
||||
// remove skus from the 'working' processingSkus table
|
||||
await db.delete(processingSkus).where(inArray(processingSkus.skuId, skuIds));
|
||||
|
||||
// be nice to the API and not send too many requests in a short time
|
||||
await sleep(100);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user