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") });
// Constants to control which imports run
const IMPORT_CATEGORIES = false;
const IMPORT_PRODUCTS = false;
const IMPORT_ORDERS = false;
const IMPORT_CATEGORIES = true;
const IMPORT_PRODUCTS = true;
const IMPORT_ORDERS = true;
const IMPORT_PURCHASE_ORDERS = true;
// SSH configuration
@@ -1405,6 +1405,7 @@ async function main() {
let ssh;
let prodConnection;
let localConnection;
const startTime = Date.now();
try {
outputProgress({
@@ -1451,16 +1452,30 @@ async function main() {
if (isImportCancelled) throw new Error("Import cancelled");
}
const endTime = Date.now();
outputProgress({
status: "complete",
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) {
const endTime = Date.now();
console.error("Error during import process:", error);
outputProgress({
status: error.message === "Import cancelled" ? "cancelled" : "error",
operation: "Import process",
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;
} finally {