diff --git a/server/data/autohouse.js b/server/data/autohouse.js index 47864271b..92851602c 100644 --- a/server/data/autohouse.js +++ b/server/data/autohouse.js @@ -39,7 +39,7 @@ exports.default = async (req, res) => { const { bodyshops } = await client.request(queries.GET_AUTOHOUSE_SHOPS); const specificShopIds = req.body.bodyshopIds; // ['uuid] - const { start, end } = req.body; //YYYY-MM-DD + const { start, end, skipUpload } = req.body; //YYYY-MM-DD const allxmlsToUpload = []; const allErrors = []; try { @@ -125,12 +125,24 @@ exports.default = async (req, res) => { } } - // for (const xmlObj of allxmlsToUpload) { - // fs.writeFileSync(`./logs/${xmlObj.filename}`, xmlObj.xml); - // } + if (skipUpload) { + for (const xmlObj of allxmlsToUpload) { + fs.writeFileSync(`./logs/${xmlObj.filename}`, xmlObj.xml); + } - // res.json(allxmlsToUpload); - // return; + res.json(allxmlsToUpload); + sendServerEmail({ + subject: `Autohouse Report ${moment().format("MM-DD-YY")}`, + text: `Errors: ${allErrors.map((e) => JSON.stringify(e, null, 2))} + Uploaded: ${JSON.stringify( + allxmlsToUpload.map((x) => ({ filename: x.filename, count: x.count })), + null, + 2 + )} + `, + }); + return; + } let sftp = new Client(); sftp.on("error", (errors) => @@ -169,7 +181,7 @@ exports.default = async (req, res) => { subject: `Autohouse Report ${moment().format("MM-DD-YY")}`, text: `Errors: ${allErrors.map((e) => JSON.stringify(e, null, 2))} Uploaded: ${JSON.stringify( - allxmlsToUpload.map((x) => x.filename), + allxmlsToUpload.map((x) => ({ filename: x.filename, count: x.count })), null, 2 )}