Track import time

This commit is contained in:
2025-01-26 23:39:01 -05:00
parent 7c7c27a71c
commit ff1de4a37d

View File

@@ -6,9 +6,9 @@ const path = require("path");
dotenv.config({ path: path.join(__dirname, "../.env") }); dotenv.config({ path: path.join(__dirname, "../.env") });
// Constants to control which imports run // Constants to control which imports run
const IMPORT_CATEGORIES = false; const IMPORT_CATEGORIES = true;
const IMPORT_PRODUCTS = false; const IMPORT_PRODUCTS = true;
const IMPORT_ORDERS = false; const IMPORT_ORDERS = true;
const IMPORT_PURCHASE_ORDERS = true; const IMPORT_PURCHASE_ORDERS = true;
// SSH configuration // SSH configuration
@@ -1405,6 +1405,7 @@ async function main() {
let ssh; let ssh;
let prodConnection; let prodConnection;
let localConnection; let localConnection;
const startTime = Date.now();
try { try {
outputProgress({ outputProgress({
@@ -1451,16 +1452,30 @@ async function main() {
if (isImportCancelled) throw new Error("Import cancelled"); if (isImportCancelled) throw new Error("Import cancelled");
} }
const endTime = Date.now();
outputProgress({ outputProgress({
status: "complete", status: "complete",
operation: "Import process completed", operation: "Import process completed",
timing: {
start_time: new Date(startTime).toISOString(),
end_time: new Date(endTime).toISOString(),
elapsed_time: formatDuration((endTime - startTime) / 1000),
elapsed_seconds: Math.round((endTime - startTime) / 1000)
}
}); });
} catch (error) { } catch (error) {
const endTime = Date.now();
console.error("Error during import process:", error); console.error("Error during import process:", error);
outputProgress({ outputProgress({
status: error.message === "Import cancelled" ? "cancelled" : "error", status: error.message === "Import cancelled" ? "cancelled" : "error",
operation: "Import process", operation: "Import process",
error: error.message, error: error.message,
timing: {
start_time: new Date(startTime).toISOString(),
end_time: new Date(endTime).toISOString(),
elapsed_time: formatDuration((endTime - startTime) / 1000),
elapsed_seconds: Math.round((endTime - startTime) / 1000)
}
}); });
throw error; throw error;
} finally { } finally {