Streamline incremental imports
This commit is contained in:
@@ -10,8 +10,8 @@ const importPurchaseOrders = require('./import/purchase-orders');
|
||||
dotenv.config({ path: path.join(__dirname, "../.env") });
|
||||
|
||||
// Constants to control which imports run
|
||||
const IMPORT_CATEGORIES = false;
|
||||
const IMPORT_PRODUCTS = false;
|
||||
const IMPORT_CATEGORIES = true;
|
||||
const IMPORT_PRODUCTS = true;
|
||||
const IMPORT_ORDERS = true;
|
||||
const IMPORT_PURCHASE_ORDERS = true;
|
||||
|
||||
@@ -48,7 +48,6 @@ const sshConfig = {
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0,
|
||||
namedPlaceholders: true,
|
||||
maxAllowedPacket: 64 * 1024 * 1024, // 64MB
|
||||
connectTimeout: 60000,
|
||||
enableKeepAlive: true,
|
||||
keepAliveInitialDelay: 10000,
|
||||
@@ -162,32 +161,32 @@ async function main() {
|
||||
results.categories = await importCategories(prodConnection, localConnection);
|
||||
if (isImportCancelled) throw new Error("Import cancelled");
|
||||
completedSteps++;
|
||||
if (results.categories.recordsAdded) totalRecordsAdded += results.categories.recordsAdded;
|
||||
if (results.categories.recordsUpdated) totalRecordsUpdated += results.categories.recordsUpdated;
|
||||
if (results.categories?.recordsAdded) totalRecordsAdded += results.categories.recordsAdded;
|
||||
if (results.categories?.recordsUpdated) totalRecordsUpdated += results.categories.recordsUpdated;
|
||||
}
|
||||
|
||||
if (IMPORT_PRODUCTS) {
|
||||
results.products = await importProducts(prodConnection, localConnection, INCREMENTAL_UPDATE);
|
||||
if (isImportCancelled) throw new Error("Import cancelled");
|
||||
completedSteps++;
|
||||
if (results.products.recordsAdded) totalRecordsAdded += results.products.recordsAdded;
|
||||
if (results.products.recordsUpdated) totalRecordsUpdated += results.products.recordsUpdated;
|
||||
if (results.products?.recordsAdded) totalRecordsAdded += results.products.recordsAdded;
|
||||
if (results.products?.recordsUpdated) totalRecordsUpdated += results.products.recordsUpdated;
|
||||
}
|
||||
|
||||
if (IMPORT_ORDERS) {
|
||||
results.orders = await importOrders(prodConnection, localConnection, INCREMENTAL_UPDATE);
|
||||
if (isImportCancelled) throw new Error("Import cancelled");
|
||||
completedSteps++;
|
||||
if (results.orders.recordsAdded) totalRecordsAdded += results.orders.recordsAdded;
|
||||
if (results.orders.recordsUpdated) totalRecordsUpdated += results.orders.recordsUpdated;
|
||||
if (results.orders?.recordsAdded) totalRecordsAdded += results.orders.recordsAdded;
|
||||
if (results.orders?.recordsUpdated) totalRecordsUpdated += results.orders.recordsUpdated;
|
||||
}
|
||||
|
||||
if (IMPORT_PURCHASE_ORDERS) {
|
||||
results.purchaseOrders = await importPurchaseOrders(prodConnection, localConnection, INCREMENTAL_UPDATE);
|
||||
if (isImportCancelled) throw new Error("Import cancelled");
|
||||
completedSteps++;
|
||||
if (results.purchaseOrders.recordsAdded) totalRecordsAdded += results.purchaseOrders.recordsAdded;
|
||||
if (results.purchaseOrders.recordsUpdated) totalRecordsUpdated += results.purchaseOrders.recordsUpdated;
|
||||
if (results.purchaseOrders?.recordsAdded) totalRecordsAdded += results.purchaseOrders.recordsAdded;
|
||||
if (results.purchaseOrders?.recordsUpdated) totalRecordsUpdated += results.purchaseOrders.recordsUpdated;
|
||||
}
|
||||
|
||||
const endTime = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user