Additional drizzle cleanup. Move scrub transformation to server side.
This commit is contained in:
@@ -6,7 +6,6 @@ import { promises as fsPromises } from "fs";
|
||||
import path from "path";
|
||||
import { RawJobDataObject } from "../decoder/decoder";
|
||||
import store from "../store/store";
|
||||
import TransformJobForEstimateScrubber from "./es-transformer";
|
||||
|
||||
// Function to write job object to logs subfolder
|
||||
async function writeJobToLogsFolder(job, fileName): Promise<string> {
|
||||
@@ -37,13 +36,13 @@ async function writeJobToLogsFolder(job, fileName): Promise<string> {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function ScrubEstimate({
|
||||
job,
|
||||
}: {
|
||||
job: RawJobDataObject;
|
||||
}): Promise<string | undefined> {
|
||||
const transformedJob = await TransformJobForEstimateScrubber(job); //Job should be transformed server side.
|
||||
|
||||
// No transformation here - send raw job to Lambda
|
||||
const currentChannel = autoUpdater.channel;
|
||||
let estimateScrubberUrl: string;
|
||||
switch (currentChannel) {
|
||||
@@ -67,29 +66,30 @@ async function ScrubEstimate({
|
||||
|
||||
try {
|
||||
const esApiKey = store.get("settings.esApiKey") as string;
|
||||
//Perform data manipulation on the job object
|
||||
if (!transformedJob) {
|
||||
|
||||
if (!job) {
|
||||
console.error("No job provided to ScrubEstimate");
|
||||
return;
|
||||
}
|
||||
|
||||
const fileName = `${esApiKey}-${transformedJob.clm_no}-${Date.now()}`;
|
||||
const fileName = `${esApiKey}-${job.clm_no}-${Date.now()}`;
|
||||
|
||||
// Write job object to logs subfolder
|
||||
try {
|
||||
await writeJobToLogsFolder(transformedJob, fileName);
|
||||
await writeJobToLogsFolder(job, fileName);
|
||||
} catch (error) {
|
||||
log.error("Failed to write job to logs folder:", error);
|
||||
// Continue with the rest of the function even if this fails
|
||||
}
|
||||
|
||||
// Send raw job to Lambda - transformation happens server-side
|
||||
const result = await axios.post(estimateScrubberUrl, {
|
||||
esApiKey,
|
||||
estimate: transformedJob,
|
||||
fileName,
|
||||
rawJob: job, // Changed from 'estimate' to 'rawJob'
|
||||
});
|
||||
|
||||
const { resultPDFUrl, reportIssueUrl } = result?.data ?? {};
|
||||
const { resultPDFUrl, reportIssueUrl, identified_item } =
|
||||
result?.data ?? {};
|
||||
|
||||
// log.log("Estimate Scrubber Result:", result.data, resultPDFUrl);
|
||||
// const b = BrowserWindow.getAllWindows()[0];
|
||||
|
||||
Reference in New Issue
Block a user