[chore] added small delay to sync-prices to not be too aggressive

This commit is contained in:
2026-03-05 07:11:54 -05:00
parent 9c13fd6e4c
commit 79b52db469

View File

@@ -12,6 +12,10 @@ const DollarToInt = (dollar: any) => {
return Math.round(dollar * 100); return Math.round(dollar * 100);
} }
function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function resetProcessingTable() { async function resetProcessingTable() {
// Use sql.raw to execute the TRUNCATE TABLE statement // Use sql.raw to execute the TRUNCATE TABLE statement
await db.execute(sql.raw('TRUNCATE TABLE processingSkus;')); await db.execute(sql.raw('TRUNCATE TABLE processingSkus;'));
@@ -80,6 +84,8 @@ async function syncPrices() {
// remove skus from the 'working' processingSkus table // remove skus from the 'working' processingSkus table
await db.delete(processingSkus).where(inArray(processingSkus.skuId, skuIds)); 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);
} }
} }