Add database fields.

This commit is contained in:
Patrick Fic
2025-08-12 08:56:58 -07:00
parent d8124495e2
commit 09ddb85b8b
11 changed files with 61 additions and 20 deletions

View File

@@ -1,7 +1,6 @@
const fs = require("fs");
const log = require("electron-log");
const axios = require("axios");
const { path } = require("path");
const { BrowserWindow } = require("electron");
// Function to write job object to logs subfolder
@@ -10,17 +9,17 @@ async function writeJobToLogsFolder(job, fileName) {
// Get the directory where electron-log stores its files
const logFilePath = log.transports.file.getFile().path;
const logsDir = path.dirname(logFilePath);
// Create a subfolder for job objects
const jobLogsDir = path.join(logsDir, 'esjson');
// Ensure the directory exists
await fsPromises.mkdir(jobLogsDir, { recursive: true });
// Write the job object as JSON
const jobFilePath = path.join(jobLogsDir, `${fileName}.json`);
await fsPromises.writeFile(jobFilePath, JSON.stringify(job, null, 2), 'utf8');
log.log(`Job object written to: ${jobFilePath}`);
return jobFilePath;
} catch (error) {
@@ -28,7 +27,6 @@ async function writeJobToLogsFolder(job, fileName) {
throw error;
}
}
async function ScrubEstimate({ job }) {
//TODO: Fetch these from ImEX Online API.
const basicAuthUser = "Imex";
@@ -60,6 +58,7 @@ async function ScrubEstimate({ job }) {
}
});
}
delete job.bodyshop //Bodyshop has to be passed through the object as we don't have access to the store here.
//Lower case the rates & totals
if (job.rates && Array.isArray(job.rates)) {
@@ -83,7 +82,7 @@ async function ScrubEstimate({ job }) {
}
console.log("*** ~ ScrubEstimate ~ job:", job);
const fileName = `RPSTest-${job.id}-${Date.now()}`;
// Write job object to logs subfolder
try {
await writeJobToLogsFolder(job, fileName);
@@ -91,7 +90,7 @@ async function ScrubEstimate({ job }) {
log.error('Failed to write job to logs folder:', error);
// Continue with the rest of the function even if this fails
}
const formData = new FormData();
const jsonString = JSON.stringify(job);
formData.append("file", new Blob([jsonString], { type: "application/json" }), `${fileName}.json`);